@wangeditor-next/yjs 0.1.1 → 0.1.2
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.esm.js +1719 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1438 -2
- package/dist/index.js.map +1 -1
- package/dist/plugins/withCursors.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,1719 @@
|
|
|
1
|
-
import{Text as t,Node as e,Path as n,Editor as r,Transforms as o}from"slate";import*as i from"yjs";var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function u(t){var e={exports:{}};return t(e,e.exports),e.exports}var c,s,f=function(t){return t&&t.Math==Math&&t},l=f("object"==typeof globalThis&&globalThis)||f("object"==typeof window&&window)||f("object"==typeof self&&self)||f("object"==typeof a&&a)||function(){return this}()||Function("return this")(),d=function(t){try{return!!t()}catch(t){return!0}},h=!d((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),p=Function.prototype.call,v=p.bind?p.bind(p):function(){return p.apply(p,arguments)},g={}.propertyIsEnumerable,y=Object.getOwnPropertyDescriptor,b=y&&!g.call({1:2},1)?function(t){var e=y(this,t);return!!e&&e.enumerable}:g,m={f:b},w=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},O=Function.prototype,S=O.bind,x=O.call,E=S&&S.bind(x),j=S?function(t){return t&&E(x,t)}:function(t){return t&&function(){return x.apply(t,arguments)}},T=j({}.toString),P=j("".slice),R=function(t){return P(T(t),8,-1)},A=l.Object,k=j("".split),C=d((function(){return!A("z").propertyIsEnumerable(0)}))?function(t){return"String"==R(t)?k(t,""):A(t)}:A,L=l.TypeError,_=function(t){if(null==t)throw L("Can't call method on "+t);return t},M=function(t){return C(_(t))},F=function(t){return"function"==typeof t},I=function(t){return"object"==typeof t?null!==t:F(t)},D=function(t,e){return arguments.length<2?(n=l[t],F(n)?n:void 0):l[t]&&l[t][e];var n},z=j({}.isPrototypeOf),N=D("navigator","userAgent")||"",W=l.process,G=l.Deno,X=W&&W.versions||G&&G.version,B=X&&X.v8;B&&(s=(c=B.split("."))[0]>0&&c[0]<4?1:+(c[0]+c[1])),!s&&N&&(!(c=N.match(/Edge\/(\d+)/))||c[1]>=74)&&(c=N.match(/Chrome\/(\d+)/))&&(s=+c[1]);var U=s,Y=!!Object.getOwnPropertySymbols&&!d((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&U&&U<41})),V=Y&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,q=l.Object,H=V?function(t){return"symbol"==typeof t}:function(t){var e=D("Symbol");return F(e)&&z(e.prototype,q(t))},J=l.String,K=function(t){try{return J(t)}catch(t){return"Object"}},$=l.TypeError,Q=function(t){if(F(t))return t;throw $(K(t)+" is not a function")},Z=function(t,e){var n=t[e];return null==n?void 0:Q(n)},tt=l.TypeError,et=Object.defineProperty,nt=function(t,e){try{et(l,t,{value:e,configurable:!0,writable:!0})}catch(n){l[t]=e}return e},rt="__core-js_shared__",ot=l[rt]||nt(rt,{}),it=u((function(t){(t.exports=function(t,e){return ot[t]||(ot[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.19.3",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),at=l.Object,ut=function(t){return at(_(t))},ct=j({}.hasOwnProperty),st=Object.hasOwn||function(t,e){return ct(ut(t),e)},ft=0,lt=Math.random(),dt=j(1..toString),ht=function(t){return"Symbol("+(void 0===t?"":t)+")_"+dt(++ft+lt,36)},pt=it("wks"),vt=l.Symbol,gt=vt&&vt.for,yt=V?vt:vt&&vt.withoutSetter||ht,bt=function(t){if(!st(pt,t)||!Y&&"string"!=typeof pt[t]){var e="Symbol."+t;Y&&st(vt,t)?pt[t]=vt[t]:pt[t]=V&>?gt(e):yt(e)}return pt[t]},mt=l.TypeError,wt=bt("toPrimitive"),Ot=function(t,e){if(!I(t)||H(t))return t;var n,r=Z(t,wt);if(r){if(void 0===e&&(e="default"),n=v(r,t,e),!I(n)||H(n))return n;throw mt("Can't convert object to primitive value")}return void 0===e&&(e="number"),function(t,e){var n,r;if("string"===e&&F(n=t.toString)&&!I(r=v(n,t)))return r;if(F(n=t.valueOf)&&!I(r=v(n,t)))return r;if("string"!==e&&F(n=t.toString)&&!I(r=v(n,t)))return r;throw tt("Can't convert object to primitive value")}(t,e)},St=function(t){var e=Ot(t,"string");return H(e)?e:e+""},xt=l.document,Et=I(xt)&&I(xt.createElement),jt=function(t){return Et?xt.createElement(t):{}},Tt=!h&&!d((function(){return 7!=Object.defineProperty(jt("div"),"a",{get:function(){return 7}}).a})),Pt=Object.getOwnPropertyDescriptor,Rt={f:h?Pt:function(t,e){if(t=M(t),e=St(e),Tt)try{return Pt(t,e)}catch(t){}if(st(t,e))return w(!v(m.f,t,e),t[e])}},At=l.String,kt=l.TypeError,Ct=function(t){if(I(t))return t;throw kt(At(t)+" is not an object")},Lt=l.TypeError,_t=Object.defineProperty,Mt={f:h?_t:function(t,e,n){if(Ct(t),e=St(e),Ct(n),Tt)try{return _t(t,e,n)}catch(t){}if("get"in n||"set"in n)throw Lt("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},Ft=h?function(t,e,n){return Mt.f(t,e,w(1,n))}:function(t,e,n){return t[e]=n,t},It=j(Function.toString);F(ot.inspectSource)||(ot.inspectSource=function(t){return It(t)});var Dt,zt,Nt,Wt=ot.inspectSource,Gt=l.WeakMap,Xt=F(Gt)&&/native code/.test(Wt(Gt)),Bt=it("keys"),Ut=function(t){return Bt[t]||(Bt[t]=ht(t))},Yt={},Vt="Object already initialized",qt=l.TypeError,Ht=l.WeakMap;if(Xt||ot.state){var Jt=ot.state||(ot.state=new Ht),Kt=j(Jt.get),$t=j(Jt.has),Qt=j(Jt.set);Dt=function(t,e){if($t(Jt,t))throw new qt(Vt);return e.facade=t,Qt(Jt,t,e),e},zt=function(t){return Kt(Jt,t)||{}},Nt=function(t){return $t(Jt,t)}}else{var Zt=Ut("state");Yt[Zt]=!0,Dt=function(t,e){if(st(t,Zt))throw new qt(Vt);return e.facade=t,Ft(t,Zt,e),e},zt=function(t){return st(t,Zt)?t[Zt]:{}},Nt=function(t){return st(t,Zt)}}var te={set:Dt,get:zt,has:Nt,enforce:function(t){return Nt(t)?zt(t):Dt(t,{})},getterFor:function(t){return function(e){var n;if(!I(e)||(n=zt(e)).type!==t)throw qt("Incompatible receiver, "+t+" required");return n}}},ee=Function.prototype,ne=h&&Object.getOwnPropertyDescriptor,re=st(ee,"name"),oe={EXISTS:re,PROPER:re&&"something"===function(){}.name,CONFIGURABLE:re&&(!h||h&&ne(ee,"name").configurable)},ie=u((function(t){var e=oe.CONFIGURABLE,n=te.get,r=te.enforce,o=String(String).split("String");(t.exports=function(t,n,i,a){var u,c=!!a&&!!a.unsafe,s=!!a&&!!a.enumerable,f=!!a&&!!a.noTargetGet,d=a&&void 0!==a.name?a.name:n;F(i)&&("Symbol("===String(d).slice(0,7)&&(d="["+String(d).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!st(i,"name")||e&&i.name!==d)&&Ft(i,"name",d),(u=r(i)).source||(u.source=o.join("string"==typeof d?d:""))),t!==l?(c?!f&&t[n]&&(s=!0):delete t[n],s?t[n]=i:Ft(t,n,i)):s?t[n]=i:nt(n,i)})(Function.prototype,"toString",(function(){return F(this)&&n(this).source||Wt(this)}))})),ae=Math.ceil,ue=Math.floor,ce=function(t){var e=+t;return e!=e||0===e?0:(e>0?ue:ae)(e)},se=Math.max,fe=Math.min,le=function(t,e){var n=ce(t);return n<0?se(n+e,0):fe(n,e)},de=Math.min,he=function(t){return t>0?de(ce(t),9007199254740991):0},pe=function(t){return he(t.length)},ve=function(t){return function(e,n,r){var o,i=M(e),a=pe(i),u=le(r,a);if(t&&n!=n){for(;a>u;)if((o=i[u++])!=o)return!0}else for(;a>u;u++)if((t||u in i)&&i[u]===n)return t||u||0;return!t&&-1}},ge={includes:ve(!0),indexOf:ve(!1)},ye=ge.indexOf,be=j([].push),me=function(t,e){var n,r=M(t),o=0,i=[];for(n in r)!st(Yt,n)&&st(r,n)&&be(i,n);for(;e.length>o;)st(r,n=e[o++])&&(~ye(i,n)||be(i,n));return i},we=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Oe=we.concat("length","prototype"),Se={f:Object.getOwnPropertyNames||function(t){return me(t,Oe)}},xe={f:Object.getOwnPropertySymbols},Ee=j([].concat),je=D("Reflect","ownKeys")||function(t){var e=Se.f(Ct(t)),n=xe.f;return n?Ee(e,n(t)):e},Te=function(t,e){for(var n=je(e),r=Mt.f,o=Rt.f,i=0;i<n.length;i++){var a=n[i];st(t,a)||r(t,a,o(e,a))}},Pe=/#|\.prototype\./,Re=function(t,e){var n=ke[Ae(t)];return n==Le||n!=Ce&&(F(e)?d(e):!!e)},Ae=Re.normalize=function(t){return String(t).replace(Pe,".").toLowerCase()},ke=Re.data={},Ce=Re.NATIVE="N",Le=Re.POLYFILL="P",_e=Re,Me=Rt.f,Fe=function(t,e){var n,r,o,i,a,u=t.target,c=t.global,s=t.stat;if(n=c?l:s?l[u]||nt(u,{}):(l[u]||{}).prototype)for(r in e){if(i=e[r],o=t.noTargetGet?(a=Me(n,r))&&a.value:n[r],!_e(c?r:u+(s?".":"#")+r,t.forced)&&void 0!==o){if(typeof i==typeof o)continue;Te(i,o)}(t.sham||o&&o.sham)&&Ft(i,"sham",!0),ie(n,r,i,t)}},Ie=Function.prototype,De=Ie.apply,ze=Ie.bind,Ne=Ie.call,We="object"==typeof Reflect&&Reflect.apply||(ze?Ne.bind(De):function(){return Ne.apply(De,arguments)}),Ge=Array.isArray||function(t){return"Array"==R(t)},Xe={};Xe[bt("toStringTag")]="z";var Be,Ue="[object z]"===String(Xe),Ye=bt("toStringTag"),Ve=l.Object,qe="Arguments"==R(function(){return arguments}()),He=Ue?R:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Ve(t),Ye))?n:qe?R(e):"Object"==(r=R(e))&&F(e.callee)?"Arguments":r},Je=l.String,Ke=function(t){if("Symbol"===He(t))throw TypeError("Cannot convert a Symbol value to a string");return Je(t)},$e=Object.keys||function(t){return me(t,we)},Qe=h?Object.defineProperties:function(t,e){Ct(t);for(var n,r=M(e),o=$e(e),i=o.length,a=0;i>a;)Mt.f(t,n=o[a++],r[n]);return t},Ze=D("document","documentElement"),tn="prototype",en="script",nn=Ut("IE_PROTO"),rn=function(){},on=function(t){return"<"+en+">"+t+"</"+en+">"},an=function(t){t.write(on("")),t.close();var e=t.parentWindow.Object;return t=null,e},un=function(){try{Be=new ActiveXObject("htmlfile")}catch(t){}var t,e,n;un="undefined"!=typeof document?document.domain&&Be?an(Be):(e=jt("iframe"),n="java"+en+":",e.style.display="none",Ze.appendChild(e),e.src=String(n),(t=e.contentWindow.document).open(),t.write(on("document.F=Object")),t.close(),t.F):an(Be);for(var r=we.length;r--;)delete un[tn][we[r]];return un()};Yt[nn]=!0;var cn=Object.create||function(t,e){var n;return null!==t?(rn[tn]=Ct(t),n=new rn,rn[tn]=null,n[nn]=t):n=un(),void 0===e?n:Qe(n,e)},sn=function(t,e,n){var r=St(e);r in t?Mt.f(t,r,w(0,n)):t[r]=n},fn=l.Array,ln=Math.max,dn=Se.f,hn="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],pn=function(t){try{return dn(t)}catch(t){return function(t,e,n){for(var r=pe(t),o=le(e,r),i=le(void 0===n?r:n,r),a=fn(ln(i-o,0)),u=0;o<i;o++,u++)sn(a,u,t[o]);return a.length=u,a}(hn)}},vn={f:function(t){return hn&&"Window"==R(t)?pn(t):dn(M(t))}},gn=j([].slice),yn={f:bt},bn=l,mn=Mt.f,wn=Mt.f,On=bt("toStringTag"),Sn=function(t,e,n){t&&!st(t=n?t:t.prototype,On)&&wn(t,On,{configurable:!0,value:e})},xn=j(j.bind),En=function(t,e){return Q(t),void 0===e?t:xn?xn(t,e):function(){return t.apply(e,arguments)}},jn=function(){},Tn=[],Pn=D("Reflect","construct"),Rn=/^\s*(?:class|function)\b/,An=j(Rn.exec),kn=!Rn.exec(jn),Cn=function(t){if(!F(t))return!1;try{return Pn(jn,Tn,t),!0}catch(t){return!1}},Ln=!Pn||d((function(){var t;return Cn(Cn.call)||!Cn(Object)||!Cn((function(){t=!0}))||t}))?function(t){if(!F(t))return!1;switch(He(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}return kn||!!An(Rn,Wt(t))}:Cn,_n=bt("species"),Mn=l.Array,Fn=function(t,e){return new(function(t){var e;return Ge(t)&&(e=t.constructor,(Ln(e)&&(e===Mn||Ge(e.prototype))||I(e)&&null===(e=e[_n]))&&(e=void 0)),void 0===e?Mn:e}(t))(0===e?0:e)},In=j([].push),Dn=function(t){var e=1==t,n=2==t,r=3==t,o=4==t,i=6==t,a=7==t,u=5==t||i;return function(c,s,f,l){for(var d,h,p=ut(c),v=C(p),g=En(s,f),y=pe(v),b=0,m=l||Fn,w=e?m(c,y):n||a?m(c,0):void 0;y>b;b++)if((u||b in v)&&(h=g(d=v[b],b,p),t))if(e)w[b]=h;else if(h)switch(t){case 3:return!0;case 5:return d;case 6:return b;case 2:In(w,d)}else switch(t){case 4:return!1;case 7:In(w,d)}return i?-1:r||o?o:w}},zn={forEach:Dn(0),map:Dn(1),filter:Dn(2),some:Dn(3),every:Dn(4),find:Dn(5),findIndex:Dn(6),filterReject:Dn(7)},Nn=zn.forEach,Wn=Ut("hidden"),Gn="Symbol",Xn="prototype",Bn=bt("toPrimitive"),Un=te.set,Yn=te.getterFor(Gn),Vn=Object[Xn],qn=l.Symbol,Hn=qn&&qn[Xn],Jn=l.TypeError,Kn=l.QObject,$n=D("JSON","stringify"),Qn=Rt.f,Zn=Mt.f,tr=vn.f,er=m.f,nr=j([].push),rr=it("symbols"),or=it("op-symbols"),ir=it("string-to-symbol-registry"),ar=it("symbol-to-string-registry"),ur=it("wks"),cr=!Kn||!Kn[Xn]||!Kn[Xn].findChild,sr=h&&d((function(){return 7!=cn(Zn({},"a",{get:function(){return Zn(this,"a",{value:7}).a}})).a}))?function(t,e,n){var r=Qn(Vn,e);r&&delete Vn[e],Zn(t,e,n),r&&t!==Vn&&Zn(Vn,e,r)}:Zn,fr=function(t,e){var n=rr[t]=cn(Hn);return Un(n,{type:Gn,tag:t,description:e}),h||(n.description=e),n},lr=function(t,e,n){t===Vn&&lr(or,e,n),Ct(t);var r=St(e);return Ct(n),st(rr,r)?(n.enumerable?(st(t,Wn)&&t[Wn][r]&&(t[Wn][r]=!1),n=cn(n,{enumerable:w(0,!1)})):(st(t,Wn)||Zn(t,Wn,w(1,{})),t[Wn][r]=!0),sr(t,r,n)):Zn(t,r,n)},dr=function(t,e){Ct(t);var n=M(e),r=$e(n).concat(gr(n));return Nn(r,(function(e){h&&!v(hr,n,e)||lr(t,e,n[e])})),t},hr=function(t){var e=St(t),n=v(er,this,e);return!(this===Vn&&st(rr,e)&&!st(or,e))&&(!(n||!st(this,e)||!st(rr,e)||st(this,Wn)&&this[Wn][e])||n)},pr=function(t,e){var n=M(t),r=St(e);if(n!==Vn||!st(rr,r)||st(or,r)){var o=Qn(n,r);return!o||!st(rr,r)||st(n,Wn)&&n[Wn][r]||(o.enumerable=!0),o}},vr=function(t){var e=tr(M(t)),n=[];return Nn(e,(function(t){st(rr,t)||st(Yt,t)||nr(n,t)})),n},gr=function(t){var e=t===Vn,n=tr(e?or:M(t)),r=[];return Nn(n,(function(t){!st(rr,t)||e&&!st(Vn,t)||nr(r,rr[t])})),r};if(Y||(Hn=(qn=function(){if(z(Hn,this))throw Jn("Symbol is not a constructor");var t=arguments.length&&void 0!==arguments[0]?Ke(arguments[0]):void 0,e=ht(t),n=function(t){this===Vn&&v(n,or,t),st(this,Wn)&&st(this[Wn],e)&&(this[Wn][e]=!1),sr(this,e,w(1,t))};return h&&cr&&sr(Vn,e,{configurable:!0,set:n}),fr(e,t)})[Xn],ie(Hn,"toString",(function(){return Yn(this).tag})),ie(qn,"withoutSetter",(function(t){return fr(ht(t),t)})),m.f=hr,Mt.f=lr,Rt.f=pr,Se.f=vn.f=vr,xe.f=gr,yn.f=function(t){return fr(bt(t),t)},h&&(Zn(Hn,"description",{configurable:!0,get:function(){return Yn(this).description}}),ie(Vn,"propertyIsEnumerable",hr,{unsafe:!0}))),Fe({global:!0,wrap:!0,forced:!Y,sham:!Y},{Symbol:qn}),Nn($e(ur),(function(t){!function(t){var e=bn.Symbol||(bn.Symbol={});st(e,t)||mn(e,t,{value:yn.f(t)})}(t)})),Fe({target:Gn,stat:!0,forced:!Y},{for:function(t){var e=Ke(t);if(st(ir,e))return ir[e];var n=qn(e);return ir[e]=n,ar[n]=e,n},keyFor:function(t){if(!H(t))throw Jn(t+" is not a symbol");if(st(ar,t))return ar[t]},useSetter:function(){cr=!0},useSimple:function(){cr=!1}}),Fe({target:"Object",stat:!0,forced:!Y,sham:!h},{create:function(t,e){return void 0===e?cn(t):dr(cn(t),e)},defineProperty:lr,defineProperties:dr,getOwnPropertyDescriptor:pr}),Fe({target:"Object",stat:!0,forced:!Y},{getOwnPropertyNames:vr,getOwnPropertySymbols:gr}),Fe({target:"Object",stat:!0,forced:d((function(){xe.f(1)}))},{getOwnPropertySymbols:function(t){return xe.f(ut(t))}}),$n){var yr=!Y||d((function(){var t=qn();return"[null]"!=$n([t])||"{}"!=$n({a:t})||"{}"!=$n(Object(t))}));Fe({target:"JSON",stat:!0,forced:yr},{stringify:function(t,e,n){var r=gn(arguments),o=e;if((I(e)||void 0!==t)&&!H(t))return Ge(e)||(e=function(t,e){if(F(o)&&(e=v(o,this,t,e)),!H(e))return e}),r[1]=e,We($n,null,r)}})}if(!Hn[Bn]){var br=Hn.valueOf;ie(Hn,Bn,(function(t){return v(br,this)}))}Sn(qn,Gn),Yt[Wn]=!0;var mr=Mt.f,wr=l.Symbol,Or=wr&&wr.prototype;if(h&&F(wr)&&(!("description"in Or)||void 0!==wr().description)){var Sr={},xr=function(){var t=arguments.length<1||void 0===arguments[0]?void 0:Ke(arguments[0]),e=z(Or,this)?new wr(t):void 0===t?wr():wr(t);return""===t&&(Sr[e]=!0),e};Te(xr,wr),xr.prototype=Or,Or.constructor=xr;var Er="Symbol(test)"==String(wr("test")),jr=j(Or.toString),Tr=j(Or.valueOf),Pr=/^Symbol\((.*)\)[^)]+$/,Rr=j("".replace),Ar=j("".slice);mr(Or,"description",{configurable:!0,get:function(){var t=Tr(this),e=jr(t);if(st(Sr,t))return"";var n=Er?Ar(e,7,-1):Rr(e,Pr,"$1");return""===n?void 0:n}}),Fe({global:!0,forced:!0},{Symbol:xr})}var kr=bt("unscopables"),Cr=Array.prototype;null==Cr[kr]&&Mt.f(Cr,kr,{configurable:!0,value:cn(null)});var Lr,_r,Mr,Fr=function(t){Cr[kr][t]=!0},Ir={},Dr=!d((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})),zr=Ut("IE_PROTO"),Nr=l.Object,Wr=Nr.prototype,Gr=Dr?Nr.getPrototypeOf:function(t){var e=ut(t);if(st(e,zr))return e[zr];var n=e.constructor;return F(n)&&e instanceof n?n.prototype:e instanceof Nr?Wr:null},Xr=bt("iterator"),Br=!1;[].keys&&("next"in(Mr=[].keys())?(_r=Gr(Gr(Mr)))!==Object.prototype&&(Lr=_r):Br=!0);var Ur=null==Lr||d((function(){var t={};return Lr[Xr].call(t)!==t}));Ur&&(Lr={}),F(Lr[Xr])||ie(Lr,Xr,(function(){return this}));var Yr={IteratorPrototype:Lr,BUGGY_SAFARI_ITERATORS:Br},Vr=Yr.IteratorPrototype,qr=function(){return this},Hr=l.String,Jr=l.TypeError,Kr=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,n={};try{(t=j(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]),e=n instanceof Array}catch(t){}return function(n,r){return Ct(n),function(t){if("object"==typeof t||F(t))return t;throw Jr("Can't set "+Hr(t)+" as a prototype")}(r),e?t(n,r):n.__proto__=r,n}}():void 0),$r=oe.PROPER,Qr=oe.CONFIGURABLE,Zr=Yr.IteratorPrototype,to=Yr.BUGGY_SAFARI_ITERATORS,eo=bt("iterator"),no="keys",ro="values",oo="entries",io=function(){return this},ao=function(t,e,n,r,o,i,a){!function(t,e,n,r){var o=e+" Iterator";t.prototype=cn(Vr,{next:w(+!r,n)}),Sn(t,o,!1),Ir[o]=qr}(n,e,r);var u,c,s,f=function(t){if(t===o&&g)return g;if(!to&&t in h)return h[t];switch(t){case no:case ro:case oo:return function(){return new n(this,t)}}return function(){return new n(this)}},l=e+" Iterator",d=!1,h=t.prototype,p=h[eo]||h["@@iterator"]||o&&h[o],g=!to&&p||f(o),y="Array"==e&&h.entries||p;if(y&&(u=Gr(y.call(new t)))!==Object.prototype&&u.next&&(Gr(u)!==Zr&&(Kr?Kr(u,Zr):F(u[eo])||ie(u,eo,io)),Sn(u,l,!0)),$r&&o==ro&&p&&p.name!==ro&&(Qr?Ft(h,"name",ro):(d=!0,g=function(){return v(p,this)})),o)if(c={values:f(ro),keys:i?g:f(no),entries:f(oo)},a)for(s in c)(to||d||!(s in h))&&ie(h,s,c[s]);else Fe({target:e,proto:!0,forced:to||d},c);return h[eo]!==g&&ie(h,eo,g,{name:o}),Ir[e]=g,c},uo="Array Iterator",co=te.set,so=te.getterFor(uo),fo=ao(Array,"Array",(function(t,e){co(this,{type:uo,target:M(t),index:0,kind:e})}),(function(){var t=so(this),e=t.target,n=t.kind,r=t.index++;return!e||r>=e.length?(t.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:e[r],done:!1}:{value:[r,e[r]],done:!1}}),"values");Ir.Arguments=Ir.Array,Fr("keys"),Fr("values"),Fr("entries");var lo=Ue?{}.toString:function(){return"[object "+He(this)+"]"};Ue||ie(Object.prototype,"toString",lo,{unsafe:!0});var ho=j("".charAt),po=j("".charCodeAt),vo=j("".slice),go=function(t){return function(e,n){var r,o,i=Ke(_(e)),a=ce(n),u=i.length;return a<0||a>=u?t?"":void 0:(r=po(i,a))<55296||r>56319||a+1===u||(o=po(i,a+1))<56320||o>57343?t?ho(i,a):r:t?vo(i,a,a+2):o-56320+(r-55296<<10)+65536}},yo={codeAt:go(!1),charAt:go(!0)}.charAt,bo="String Iterator",mo=te.set,wo=te.getterFor(bo);ao(String,"String",(function(t){mo(this,{type:bo,string:Ke(t),index:0})}),(function(){var t,e=wo(this),n=e.string,r=e.index;return r>=n.length?{value:void 0,done:!0}:(t=yo(n,r),e.index+=t.length,{value:t,done:!1})}));var Oo=function(t,e,n){for(var r in e)ie(t,r,e[r],n);return t},So=d((function(){if("function"==typeof ArrayBuffer){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}})),xo=Object.isExtensible,Eo=d((function(){xo(1)}))||So?function(t){return!!I(t)&&((!So||"ArrayBuffer"!=R(t))&&(!xo||xo(t)))}:xo,jo=!d((function(){return Object.isExtensible(Object.preventExtensions({}))})),To=u((function(t){var e=Mt.f,n=!1,r=ht("meta"),o=0,i=function(t){e(t,r,{value:{objectID:"O"+o++,weakData:{}}})},a=t.exports={enable:function(){a.enable=function(){},n=!0;var t=Se.f,e=j([].splice),o={};o[r]=1,t(o).length&&(Se.f=function(n){for(var o=t(n),i=0,a=o.length;i<a;i++)if(o[i]===r){e(o,i,1);break}return o},Fe({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:vn.f}))},fastKey:function(t,e){if(!I(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!st(t,r)){if(!Eo(t))return"F";if(!e)return"E";i(t)}return t[r].objectID},getWeakData:function(t,e){if(!st(t,r)){if(!Eo(t))return!0;if(!e)return!1;i(t)}return t[r].weakData},onFreeze:function(t){return jo&&n&&Eo(t)&&!st(t,r)&&i(t),t}};Yt[r]=!0})),Po=bt("iterator"),Ro=Array.prototype,Ao=function(t){return void 0!==t&&(Ir.Array===t||Ro[Po]===t)},ko=bt("iterator"),Co=function(t){if(null!=t)return Z(t,ko)||Z(t,"@@iterator")||Ir[He(t)]},Lo=l.TypeError,_o=function(t,e){var n=arguments.length<2?Co(t):e;if(Q(n))return Ct(v(n,t));throw Lo(K(t)+" is not iterable")},Mo=function(t,e,n){var r,o;Ct(t);try{if(!(r=Z(t,"return"))){if("throw"===e)throw n;return n}r=v(r,t)}catch(t){o=!0,r=t}if("throw"===e)throw n;if(o)throw r;return Ct(r),n},Fo=l.TypeError,Io=function(t,e){this.stopped=t,this.result=e},Do=Io.prototype,zo=function(t,e,n){var r,o,i,a,u,c,s,f=n&&n.that,l=!(!n||!n.AS_ENTRIES),d=!(!n||!n.IS_ITERATOR),h=!(!n||!n.INTERRUPTED),p=En(e,f),g=function(t){return r&&Mo(r,"normal",t),new Io(!0,t)},y=function(t){return l?(Ct(t),h?p(t[0],t[1],g):p(t[0],t[1])):h?p(t,g):p(t)};if(d)r=t;else{if(!(o=Co(t)))throw Fo(K(t)+" is not iterable");if(Ao(o)){for(i=0,a=pe(t);a>i;i++)if((u=y(t[i]))&&z(Do,u))return u;return new Io(!1)}r=_o(t,o)}for(c=r.next;!(s=v(c,r)).done;){try{u=y(s.value)}catch(t){Mo(r,"throw",t)}if("object"==typeof u&&u&&z(Do,u))return u}return new Io(!1)},No=l.TypeError,Wo=function(t,e){if(z(e,t))return t;throw No("Incorrect invocation")},Go=bt("iterator"),Xo=!1;try{var Bo=0,Uo={next:function(){return{done:!!Bo++}},return:function(){Xo=!0}};Uo[Go]=function(){return this},Array.from(Uo,(function(){throw 2}))}catch(t){}var Yo=function(t,e){if(!e&&!Xo)return!1;var n=!1;try{var r={};r[Go]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n},Vo=function(t,e,n){var r=-1!==t.indexOf("Map"),o=-1!==t.indexOf("Weak"),i=r?"set":"add",a=l[t],u=a&&a.prototype,c=a,s={},f=function(t){var e=j(u[t]);ie(u,t,"add"==t?function(t){return e(this,0===t?0:t),this}:"delete"==t?function(t){return!(o&&!I(t))&&e(this,0===t?0:t)}:"get"==t?function(t){return o&&!I(t)?void 0:e(this,0===t?0:t)}:"has"==t?function(t){return!(o&&!I(t))&&e(this,0===t?0:t)}:function(t,n){return e(this,0===t?0:t,n),this})};if(_e(t,!F(a)||!(o||u.forEach&&!d((function(){(new a).entries().next()})))))c=n.getConstructor(e,t,r,i),To.enable();else if(_e(t,!0)){var h=new c,p=h[i](o?{}:-0,1)!=h,v=d((function(){h.has(1)})),g=Yo((function(t){new a(t)})),y=!o&&d((function(){for(var t=new a,e=5;e--;)t[i](e,e);return!t.has(-0)}));g||((c=e((function(t,e){Wo(t,u);var n=function(t,e,n){var r,o;return Kr&&F(r=e.constructor)&&r!==n&&I(o=r.prototype)&&o!==n.prototype&&Kr(t,o),t}(new a,t,c);return null!=e&&zo(e,n[i],{that:n,AS_ENTRIES:r}),n}))).prototype=u,u.constructor=c),(v||y)&&(f("delete"),f("has"),r&&f("get")),(y||p)&&f(i),o&&u.clear&&delete u.clear}return s[t]=c,Fe({global:!0,forced:c!=a},s),Sn(c,t),o||n.setStrong(c,t,r),c},qo=To.getWeakData,Ho=te.set,Jo=te.getterFor,Ko=zn.find,$o=zn.findIndex,Qo=j([].splice),Zo=0,ti=function(t){return t.frozen||(t.frozen=new ei)},ei=function(){this.entries=[]},ni=function(t,e){return Ko(t.entries,(function(t){return t[0]===e}))};ei.prototype={get:function(t){var e=ni(this,t);if(e)return e[1]},has:function(t){return!!ni(this,t)},set:function(t,e){var n=ni(this,t);n?n[1]=e:this.entries.push([t,e])},delete:function(t){var e=$o(this.entries,(function(e){return e[0]===t}));return~e&&Qo(this.entries,e,1),!!~e}};var ri,oi={getConstructor:function(t,e,n,r){var o=t((function(t,o){Wo(t,i),Ho(t,{type:e,id:Zo++,frozen:void 0}),null!=o&&zo(o,t[r],{that:t,AS_ENTRIES:n})})),i=o.prototype,a=Jo(e),u=function(t,e,n){var r=a(t),o=qo(Ct(e),!0);return!0===o?ti(r).set(e,n):o[r.id]=n,t};return Oo(i,{delete:function(t){var e=a(this);if(!I(t))return!1;var n=qo(t);return!0===n?ti(e).delete(t):n&&st(n,e.id)&&delete n[e.id]},has:function(t){var e=a(this);if(!I(t))return!1;var n=qo(t);return!0===n?ti(e).has(t):n&&st(n,e.id)}}),Oo(i,n?{get:function(t){var e=a(this);if(I(t)){var n=qo(t);return!0===n?ti(e).get(t):n?n[e.id]:void 0}},set:function(t,e){return u(this,t,e)}}:{add:function(t){return u(this,t,!0)}}),o}},ii=te.enforce,ai=!l.ActiveXObject&&"ActiveXObject"in l,ui=function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},ci=Vo("WeakMap",ui,oi);if(Xt&&ai){ri=oi.getConstructor(ui,"WeakMap",!0),To.enable();var si=ci.prototype,fi=j(si.delete),li=j(si.has),di=j(si.get),hi=j(si.set);Oo(si,{delete:function(t){if(I(t)&&!Eo(t)){var e=ii(this);return e.frozen||(e.frozen=new ri),fi(this,t)||e.frozen.delete(t)}return fi(this,t)},has:function(t){if(I(t)&&!Eo(t)){var e=ii(this);return e.frozen||(e.frozen=new ri),li(this,t)||e.frozen.has(t)}return li(this,t)},get:function(t){if(I(t)&&!Eo(t)){var e=ii(this);return e.frozen||(e.frozen=new ri),li(this,t)?di(this,t):e.frozen.get(t)}return di(this,t)},set:function(t,e){if(I(t)&&!Eo(t)){var n=ii(this);n.frozen||(n.frozen=new ri),li(this,t)?hi(this,t,e):n.frozen.set(t,e)}else hi(this,t,e);return this}})}Vo("WeakSet",(function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}}),oi);var pi,vi,gi={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},yi=jt("span").classList,bi=yi&&yi.constructor&&yi.constructor.prototype,mi=bi===Object.prototype?void 0:bi,wi=zn.forEach,Oi=!!(vi=[]["forEach"])&&d((function(){vi.call(null,pi||function(){throw 1},1)}))?[].forEach:function(t){return wi(this,t,arguments.length>1?arguments[1]:void 0)},Si=function(t){if(t&&t.forEach!==Oi)try{Ft(t,"forEach",Oi)}catch(e){t.forEach=Oi}};for(var xi in gi)gi[xi]&&Si(l[xi]&&l[xi].prototype);Si(mi);var Ei=bt("iterator"),ji=bt("toStringTag"),Ti=fo.values,Pi=function(t,e){if(t){if(t[Ei]!==Ti)try{Ft(t,Ei,Ti)}catch(e){t[Ei]=Ti}if(t[ji]||Ft(t,ji,e),gi[e])for(var n in fo)if(t[n]!==fo[n])try{Ft(t,n,fo[n])}catch(e){t[n]=fo[n]}}};for(var Ri in gi)Pi(l[Ri]&&l[Ri].prototype,Ri);Pi(mi,"DOMTokenList");var Ai=function(){return Ai=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ai.apply(this,arguments)};function ki(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}function Ci(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Li(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function _i(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var Mi=function(t,e,n,r){try{return r?e(Ct(n)[0],n[1]):e(n)}catch(e){Mo(t,"throw",e)}},Fi=l.Array,Ii=!Yo((function(t){Array.from(t)}));Fe({target:"Array",stat:!0,forced:Ii},{from:function(t){var e=ut(t),n=Ln(this),r=arguments.length,o=r>1?arguments[1]:void 0,i=void 0!==o;i&&(o=En(o,r>2?arguments[2]:void 0));var a,u,c,s,f,l,d=Co(e),h=0;if(!d||this==Fi&&Ao(d))for(a=pe(e),u=n?new this(a):Fi(a);a>h;h++)l=i?o(e[h],h):e[h],sn(u,h,l);else for(f=(s=_o(e,d)).next,u=n?new this:[];!(c=v(f,s)).done;h++)l=i?Mi(s,o,[c.value,h],!0):c.value,sn(u,h,l);return u.length=h,u}});var Di=bt("species"),zi=function(t){return U>=51||!d((function(){var e=[];return(e.constructor={})[Di]=function(){return{foo:1}},1!==e[t](Boolean).foo}))},Ni=zn.map,Wi=zi("map");Fe({target:"Array",proto:!0,forced:!Wi},{map:function(t){return Ni(this,t,arguments.length>1?arguments[1]:void 0)}});var Gi=zi("slice"),Xi=bt("species"),Bi=l.Array,Ui=Math.max;Fe({target:"Array",proto:!0,forced:!Gi},{slice:function(t,e){var n,r,o,i=M(this),a=pe(i),u=le(t,a),c=le(void 0===e?a:e,a);if(Ge(i)&&(n=i.constructor,(Ln(n)&&(n===Bi||Ge(n.prototype))||I(n)&&null===(n=n[Xi]))&&(n=void 0),n===Bi||void 0===n))return gn(i,u,c);for(r=new(void 0===n?Bi:n)(Ui(c-u,0)),o=0;u<c;u++,o++)u in i&&sn(r,o,i[u]);return r.length=o,r}}),Fe({target:"Object",stat:!0},{fromEntries:function(t){var e={};return zo(t,(function(t,n){sn(e,t,n)}),{AS_ENTRIES:!0}),e}});var Yi=d((function(){$e(1)}));Fe({target:"Object",stat:!0,forced:Yi},{keys:function(t){return $e(ut(t))}});var Vi=m.f,qi=j(Vi),Hi=j([].push),Ji=function(t){return function(e){for(var n,r=M(e),o=$e(r),i=o.length,a=0,u=[];i>a;)n=o[a++],h&&!qi(r,n)||Hi(u,t?[n,r[n]]:r[n]);return u}},Ki={entries:Ji(!0),values:Ji(!1)}.entries;Fe({target:"Object",stat:!0},{entries:function(t){return Ki(t)}});var $i=zn.filter,Qi=zi("filter");Fe({target:"Array",proto:!0,forced:!Qi},{filter:function(t){return $i(this,t,arguments.length>1?arguments[1]:void 0)}});var Zi=ge.includes;Fe({target:"Array",proto:!0},{includes:function(t){return Zi(this,t,arguments.length>1?arguments[1]:void 0)}}),Fr("includes");var ta=oe.PROPER,ea="toString",na=RegExp.prototype,ra=na[ea],oa=j((function(){var t=Ct(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e})),ia=d((function(){return"/a/b"!=ra.call({source:"a",flags:"b"})})),aa=ta&&ra.name!=ea;function ua(t){return"[object Object]"===Object.prototype.toString.call(t)}function ca(t){if(!ua(t))return!1;var e=t.constructor;if(void 0===e)return!0;var n=e.prototype;return!1!==ua(n)&&!Object.prototype.hasOwnProperty.call(n,"isPrototypeOfOf")}function sa(t,e){for(var n in t){var r=t[n],o=e[n];if(ca(r)&&ca(o)){if(!sa(r,o))return!1}else if(Array.isArray(r)&&Array.isArray(o)){if(r.length!==o.length)return!1;for(var i=0;i<r.length;i++)if(r[i]!==o[i])return!1}else if(r!==o)return!1}for(var n in e)if(void 0===t[n]&&void 0!==e[n])return!1;return!0}function fa(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return Object.fromEntries(Object.entries(t).filter((function(t){var n=Li(t,1)[0];return e.includes(n)})))}function la(t){return function(t){var e,n,r,o,i=[];try{for(var a=Ci(t),u=a.next();!u.done;u=a.next()){var c=u.value;if("string"!=typeof c.insert||0!==c.insert.length){var s=i[i.length-1];s&&"string"==typeof s.insert&&"string"==typeof c.insert&&(s.attributes===c.attributes||!s.attributes==!c.attributes&&sa(null!==(r=s.attributes)&&void 0!==r?r:{},null!==(o=c.attributes)&&void 0!==o?o:{}))?s.insert+=c.insert:i.push(c)}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return i}(t.toDelta())}function da(t){var e=t.insert;return"string"==typeof e?e.length:1}function ha(t){return t.reduce((function(t,e){return t+da(e)}),0)}function pa(t,e,n){if(n<1)return[];for(var r=0,o=[],i=e+n,a=0;a<t.length&&!(r>=i);a++){var u=t[a],c=da(u);if(r+c<=e)r+=c;else if("string"==typeof u.insert){var s=Math.max(0,e-r),f=Math.min(c,c-(r+c-i));o.push(Ai(Ai({},u),{insert:u.insert.slice(s,f)})),r+=c}else r+=c,o.push(u)}return o}function va(e){return function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return Object.fromEntries(Object.entries(t).filter((function(t){var n=Li(t,1)[0];return!e.includes(n)})))}(e,t.isText(e)?"text":"children")}function ga(t){var e=la(t),n=e.length>0?e.map(ya):[{text:""}];return Ai(Ai({},t.getAttributes()),{children:n})}function ya(t){return"string"==typeof t.insert?Ai(Ai({},t.attributes),{text:t.insert}):ga(t.insert)}function ba(e){return e.map((function(e){return t.isText(e)?{insert:e.text,attributes:va(e)}:{insert:ma(e)}}))}function ma(t){var e=t.children,n=ki(t,["children"]),r=new i.XmlText;return Object.entries(n).forEach((function(t){var e=Li(t,2),n=e[0],o=e[1];r.setAttribute(n,o)})),r.applyDelta(ba(e),{sanitize:!1}),r}(ia||aa)&&ie(RegExp.prototype,ea,(function(){var t=Ct(this),e=Ke(t.source),n=t.flags;return"/"+e+"/"+Ke(void 0===n&&z(na,t)&&!("flags"in na)?oa(t):n)}),{unsafe:!0});var wa=bt("isConcatSpreadable"),Oa=9007199254740991,Sa="Maximum allowed index exceeded",xa=l.TypeError,Ea=U>=51||!d((function(){var t=[];return t[wa]=!1,t.concat()[0]!==t})),ja=zi("concat"),Ta=function(t){if(!I(t))return!1;var e=t[wa];return void 0!==e?!!e:Ge(t)};function Pa(e){return e?t.isText(e)?e.text.length:1:0}function Ra(e,n,r){var o;if(0===r.length)throw new Error("Path has to a have a length >= 1");if(t.isText(n))throw new Error("Cannot descent into slate text");var a=Li(r),u=a[0],c=a.slice(1),s=function(t,e){return t.children.slice(0,e).reduce((function(t,e){return t+Pa(e)}),0)}(n,u),f=n.children[u],l=la(e),d=Pa(f),h=pa(l,s,d);if(h.length>1)throw new Error("Path doesn't match yText, yTarget spans multiple nodes");var p=null===(o=h[0])||void 0===o?void 0:o.insert;if(c.length>0){if(!(p instanceof i.XmlText))throw new Error("Path doesn't match yText, cannot descent into non-yText");return Ra(p,f,c)}return{yParent:e,textRange:{start:s,end:s+d},yTarget:p instanceof i.XmlText?p:void 0,slateParent:n,slateTarget:f,targetDelta:h}}function Aa(e,n,r){void 0===r&&(r={});for(var o=r.assoc,i=void 0===o?0:o,a=r.insert,u=void 0!==a&&a,c=0,s=0,f=0;f<e.children.length;f++){var l=e.children[f],d=t.isText(l)?l.text.length:1;d>0&&(s=f);var h=c+d;if(d>0&&(i>=0?h>n:h>=n))return[f,n-c];c+=d}if(n>c+(u?1:0))throw new Error("yOffset out of bounds");if(u)return[e.children.length,0];var p=e.children[s];return[s,t.isText(p)?p.text.length:1]}function ka(e,n,r){for(var o=[r];o[0]!==e;){var a=o[0].parent;if(!a)throw new Error("yText isn't a descendant of root element");if(!(a instanceof i.XmlText))throw new Error("Unexpected y parent type");o.unshift(a)}if(o.length<2)return[];var u=n;return o.reduce((function(e,n,r){var i,a,c=o[r+1];if(!c)return e;var s=0,f=la(n);try{for(var l=Ci(f),d=l.next();!d.done;d=l.next()){var h=d.value;if(h.insert===c)break;s+="string"==typeof h.insert?h.insert.length:1}}catch(t){i={error:t}}finally{try{d&&!d.done&&(a=l.return)&&a.call(l)}finally{if(i)throw i.error}}if(t.isText(u))throw new Error("Cannot descent into slate text");var p=Li(Aa(u,s),1)[0];return u=u.children[p],e.concat(p)}),[])}function Ca(r,o,a){var u=a.target,c=a.changes,s=a.delta;if(!(u instanceof i.XmlText))throw new Error("Unexpected target node type");var f=[],l=ka(r,o,u),d=e.get(o,l);if(t.isText(d))throw new Error("Cannot apply yTextEvent to text node");var h=Array.from(c.keys.entries());if(l.length>0&&h.length>0){var p=Object.fromEntries(h.map((function(t){var e=Li(t,2),n=e[0];return[n,"delete"===e[1].action?null:u.getAttribute(n)]}))),v=Object.fromEntries(h.map((function(t){var e=Li(t,1)[0];return[e,d[e]]})));f.push({type:"set_node",newProperties:p,properties:v,path:l})}return s.length>0&&f.push.apply(f,_i([],Li(function(e,r,o){var i=[],a=o.reduce((function(t,e){return"retain"in e?t+e.retain:"delete"in e?t+e.delete:t}),0);return o.reverse().forEach((function(o){var u,c;if("attributes"in o&&"retain"in o)for(var s=Li(Aa(e,a-o.retain),2),f=s[0],l=s[1],d=Li(Aa(e,a,{assoc:-1}),2),h=d[0],p=d[1],v=h;v>=f;v--){var g=e.children[v],y=_i(_i([],Li(r)),[v]);if(t.isText(g)){var b=o.attributes,m=fa.apply(void 0,_i([e],Li(Object.keys(o.attributes))));if(v===f||v===h){var w=v===f?l:0;if((x=v===h?p:g.text.length)!==g.text.length&&i.push({type:"split_node",path:y,position:x,properties:va(g)}),0!==w){i.push({type:"split_node",path:y,position:w,properties:(c=Ai(Ai({},va(g)),b),Object.fromEntries(Object.entries(c).filter((function(t){return null!==Li(t,2)[1]}))))});continue}}i.push({type:"set_node",newProperties:b,path:y,properties:m})}}if("retain"in o&&(a-=o.retain),"delete"in o){var O=Li(Aa(e,a-o.delete),2),S=(f=O[0],l=O[1],Li(Aa(e,a,{assoc:-1}),2));for(h=S[0],v=0===(p=S[1])?h-1:h;v>=f;v--)if(g=e.children[v],y=_i(_i([],Li(r)),[v]),!t.isText(g)||v!==f&&v!==h)i.push({type:"remove_node",node:g,path:y}),a-=Pa(g);else{w=v===f?l:0;var x=v===h?p:g.text.length;i.push({type:"remove_text",offset:w,text:g.text.slice(w,x),path:y}),a-=x-w}}else if("insert"in o){var E=Li(Aa(e,a,{insert:!0}),2),j=(v=E[0],E[1]);if(g=e.children[v],y=_i(_i([],Li(r)),[v]),t.isText(g)){var T=i[i.length-1],P=null!=T&&"insert_node"===T.type?T.node:va(g),R=[];if(null==T||"insert_node"!==T.type&&"insert_text"!==T.type&&"split_node"!==T.type&&"set_node"!==T.type||(R=T.path),"string"==typeof o.insert&&sa(null!==(u=o.attributes)&&void 0!==u?u:{},P)&&n.equals(y,R))return i.push({type:"insert_text",offset:j,text:o.insert,path:y});var A=ya(o);return 0===j?i.push({type:"insert_node",path:y,node:A}):(j<g.text.length&&i.push({type:"split_node",path:y,position:j,properties:va(g)}),i.push({type:"insert_node",path:n.next(y),node:A}))}return i.push({type:"insert_node",path:y,node:ya(o)})}})),i}(d,l,s)))),f}function La(t,e,n){r.withoutNormalizing(e,(function(){n.forEach((function(n){(function(t,e,n){if(n instanceof i.YTextEvent)return Ca(t,e,n);throw new Error("Unexpected Y event type")})(t,e,n).forEach((function(t){e.apply(t)}))}))}))}function _a(t){return t.map((function(t){return"string"==typeof t.insert?t:Ai(Ai({},t),{insert:Ma(t.insert)})}))}function Ma(t){var e=new i.XmlText,n=t.getAttributes();return Object.entries(n).forEach((function(t){var n=Li(t,2),r=n[0],o=n[1];e.setAttribute(r,o)})),e.applyDelta(_a(la(t)),{sanitize:!1}),e}Fe({target:"Array",proto:!0,forced:!Ea||!ja},{concat:function(t){var e,n,r,o,i,a=ut(this),u=Fn(a,0),c=0;for(e=-1,r=arguments.length;e<r;e++)if(Ta(i=-1===e?a:arguments[e])){if(c+(o=pe(i))>Oa)throw xa(Sa);for(n=0;n<o;n++,c++)n in i&&sn(u,c,i[n])}else{if(c>=Oa)throw xa(Sa);sn(u,c++,i)}return u.length=c,u}});var Fa=Object.assign,Ia=Object.defineProperty,Da=j([].concat),za=!Fa||d((function(){if(h&&1!==Fa({b:1},Fa(Ia({},"a",{enumerable:!0,get:function(){Ia(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach((function(t){e[t]=t})),7!=Fa({},t)[n]||$e(Fa({},e)).join("")!=r}))?function(t,e){for(var n=ut(t),r=arguments.length,o=1,i=xe.f,a=m.f;r>o;)for(var u,c=C(arguments[o++]),s=i?Da($e(c),i(c)):$e(c),f=s.length,l=0;f>l;)u=s[l++],h&&!v(a,c,u)||(n[u]=c[u]);return n}:Fa;Fe({target:"Object",stat:!0,forced:Object.assign!==za},{assign:za});var Na,Wa=bt("match"),Ga=l.TypeError,Xa=function(t){if(function(t){var e;return I(t)&&(void 0!==(e=t[Wa])?!!e:"RegExp"==R(t))}(t))throw Ga("The method doesn't accept regular expressions");return t},Ba=bt("match"),Ua=Rt.f,Ya=j("".startsWith),Va=j("".slice),qa=Math.min,Ha=function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[Ba]=!1,"/./"[t](e)}catch(t){}}return!1}("startsWith"),Ja=!(Ha||(Na=Ua(String.prototype,"startsWith"),!Na||Na.writable));Fe({target:"String",proto:!0,forced:!Ja&&!Ha},{startsWith:function(t){var e=Ke(_(this));Xa(t);var n=he(qa(arguments.length>1?arguments[1]:void 0,e.length)),r=Ke(t);return Ya?Ya(e,r,n):Va(e,n,n+r.length)===r}});var Ka=/"/g,$a=j("".replace);function Qa(t){if(!t.doc)throw new Error("shared type isn't attached to a document")}Fe({target:"String",proto:!0,forced:function(t){return d((function(){var e=""[t]('"');return e!==e.toLowerCase()||e.split('"').length>3}))}("anchor")},{anchor:function(t){return e="a",n="name",r=t,o=Ke(_(this)),i="<"+e,""!==n&&(i+=" "+n+'="'+$a(Ke(r),Ka,""")+'"'),i+">"+o+"</"+e+">";var e,n,r,o,i}});var Za="__slateYjsStoredPosition_";function tu(t,e,n){var r=Ra(t,e,n.path),o=r.yTarget,a=r.yParent,u=r.textRange;if(o)throw new Error("Slate point points to a non-text element inside sharedRoot");var c=u.start+n.offset;return i.createRelativePositionFromTypeIndex(a,c,c===u.end?-1:0)}function eu(n,r,o){if(!n.doc)throw new Error("sharedRoot isn't attach to a yDoc");var a=i.createAbsolutePositionFromRelativePosition(o,n.doc);return a&&function(n,r,o){var a=o.type,u=o.index,c=o.assoc;if(!(a instanceof i.XmlText))throw new Error("Absolute position points to a non-XMLText");var s=ka(n,r,a),f=e.get(r,s);if(t.isText(f))throw new Error("Absolute position doesn't match slateRoot, cannot descent into text");var l=Li(Aa(f,u,{assoc:c}),2),d=l[0],h=l[1],p=f.children[d];return t.isText(p)?{path:_i(_i([],Li(s)),[d]),offset:h}:null}(n,r,a)}function nu(t,e,n){t.setAttribute(Za+e,i.encodeRelativePosition(n))}function ru(t,e,n){return Object.fromEntries(Object.entries(t).filter((function(t){var r=Li(t,2)[1];return r.type===e&&(!n||(r.assoc>=0?r.index>=n.start&&r.index<n.end:r.index>n.start&&r.index>=n.end))})))}function ou(t,e,n){var r;void 0===n&&(n="");var o=((r={})[n]=ru(t,e),r);return la(e).forEach((function(e,r){var a=e.insert;a instanceof i.XmlText&&Object.assign(o,ou(t,a,n?n+"."+r:r.toString()))})),o}function iu(t,e,n,r){void 0===r&&(r=0);var o=function(t){return Qa(t),Object.fromEntries(Object.entries(t.getAttributes()).filter((function(t){return Li(t,1)[0].startsWith(Za)})).map((function(e){var n=Li(e,2),r=n[0],o=n[1];return[r.slice(Za.length),i.createAbsolutePositionFromRelativePosition(i.decodeRelativePosition(o),t.doc)]})).filter((function(t){return Li(t,2)[1]})))}(t),a={"":ru(o,e,{start:r,end:r+ha(n)})};return n.forEach((function(t,e){var n=t.insert;n instanceof i.XmlText&&Object.assign(a,ou(o,n,e.toString()))})),a}function au(t,e,n,r,o,a,u){void 0===o&&(o=0),void 0===a&&(a=0),void 0===u&&(u="");var c=n[u];c&&Object.entries(c).forEach((function(n){var r=Li(n,2),u=r[0],c=r[1];nu(t,u,i.createRelativePositionFromTypeIndex(e,c.index-a+o,c.assoc))})),r.forEach((function(e,r){var o=e.insert;o instanceof i.XmlText&&au(t,o,n,la(o),0,0,u?u+"."+r:r.toString())}))}function uu(t,e,n){return{anchor:tu(t,e,n.anchor),focus:tu(t,e,n.focus)}}function cu(t,e,n){var r=eu(t,e,n.anchor);if(!r)return null;var o=eu(t,e,n.focus);return o?{anchor:r,focus:o}:null}var su={insert_node:function(e,n,r){var o=Ra(e,n,r.path),i=o.yParent,a=o.textRange;if(t.isText(r.node))return i.insert(a.start,r.node.text,va(r.node));i.insertEmbed(a.start,ma(r.node))},remove_node:function(t,e,n){var r=Ra(t,e,n.path),o=r.yParent,i=r.textRange;o.delete(i.start,i.end-i.start)},set_node:function(t,e,n){var r=Ra(t,e,n.path),o=r.yTarget,i=r.textRange,a=r.yParent;if(o)return Object.entries(n.newProperties).forEach((function(t){var e=Li(t,2),n=e[0],r=e[1];if(null===r)return o.removeAttribute(n);o.setAttribute(n,r)})),Object.entries(n.properties).forEach((function(t){var e=Li(t,1)[0];Object.prototype.hasOwnProperty.call(n.newProperties,e)||o.removeAttribute(e)}));var u=Object.fromEntries(Object.keys(n.properties).map((function(t){return[t,null]}))),c=Ai(Ai({},u),n.newProperties);a.format(i.start,i.end-i.start,c)},merge_node:function(r,o,i){var a=Ra(r,o,i.path),u=Ra(a.yParent,a.slateParent,n.previous(i.path.slice(-1)));if(!a.yTarget!=!u.yTarget)throw new Error("Cannot merge y text with y element");if(!u.yTarget||!a.yTarget){var c=a.yParent,s=a.textRange,f=a.slateTarget;if(!f)throw new Error("Expected Slate target node for merge op.");var l=e.get(o,n.previous(i.path));if(!t.isText(l))throw new Error("Path points to Y.Text but not a Slate text node.");var d=va(f),h=va(l),p=Object.keys(d).reduce((function(t,e){var n;return e in h?t:Ai(Ai({},t),((n={})[e]=null,n))}),{});return c.format(s.start,s.end-s.start,Ai(Ai({},p),h))}var v=u.yTarget.length,g=la(a.yTarget),y=_a(g),b=iu(r,a.yTarget,g,v),m=_i([{retain:v}],Li(y));u.yTarget.applyDelta(m,{sanitize:!1}),a.yParent.delete(a.textRange.start,a.textRange.end-a.textRange.start),au(r,u.yTarget,b,y,v)},move_node:function(r,o,i){var a=n.parent(i.newPath),u=i.newPath[i.newPath.length-1],c=e.get(o,a);if(t.isText(c))throw new Error("Cannot move slate node into text element");var s=_i(_i([],Li(a)),[Math.min(u,c.children.length)]),f=Ra(r,o,i.path),l=Ra(r,o,s),d=_a(f.targetDelta),h=iu(r,f.yParent,f.targetDelta);f.yParent.delete(f.textRange.start,f.textRange.end-f.textRange.start);var p=ha(la(l.yParent)),v=Math.min(l.textRange.start,p),g=_i([{retain:v}],Li(d));l.yParent.applyDelta(g,{sanitize:!1}),au(r,l.yParent,h,d,v,f.textRange.start)},split_node:function(e,n,r){var o=Ra(e,n,r.path);if(!o.slateTarget)throw new Error("Y target without corresponding slate node");if(!o.yTarget){if(!t.isText(o.slateTarget))throw new Error("Mismatch node type between y target and slate node");var a={};return o.targetDelta.forEach((function(t){t.attributes&&Object.keys(t.attributes).forEach((function(t){a[t]=null}))})),o.yParent.format(o.textRange.start,o.textRange.end-o.textRange.start,Ai(Ai({},a),r.properties))}if(t.isText(o.slateTarget))throw new Error("Mismatch node type between y target and slate node");var u=Ra(o.yTarget,o.slateTarget,[r.position]),c=o.slateTarget.children.slice(0,r.position).reduce((function(t,e){return t+Pa(e)}),0),s=o.slateTarget.children.reduce((function(t,e){return t+Pa(e)}),0),f=pa(la(o.yTarget),c,s-c),l=_a(f),d=iu(e,o.yTarget,f,c),h=new i.XmlText;h.applyDelta(l,{sanitize:!1}),Object.entries(r.properties).forEach((function(t){var e=Li(t,2),n=e[0],r=e[1];h.setAttribute(n,r)})),o.yTarget.delete(u.textRange.start,o.yTarget.length-u.textRange.start),o.yParent.insertEmbed(o.textRange.end,h),au(e,h,d,l,0,c)}};var fu=Ai(Ai(Ai({},{insert_text:function(n,r,o){var i=Ra(n,r,o.path),a=i.yParent,u=i.textRange,c=e.get(r,o.path);if(!t.isText(c))throw new Error("Cannot insert text into non-text node");a.insert(u.start+o.offset,o.text,va(c))},remove_text:function(t,e,n){var r=Ra(t,e,n.path),o=r.yParent,i=r.textRange;o.delete(i.start+n.offset,n.text.length)}}),su),{set_selection:function(){}});var lu=Symbol("slate-yjs-operation"),du=Symbol("slate-yjs-position-storage"),hu=new WeakMap,pu=new WeakMap,vu=new WeakSet,gu={isYjsEditor:function(t){return r.isEditor(t)&&t.sharedRoot instanceof i.XmlText&&"localOrigin"in t&&"positionStorageOrigin"in t&&"function"==typeof t.applyRemoteEvents&&"function"==typeof t.storeLocalChange&&"function"==typeof t.flushLocalChanges&&"function"==typeof t.isLocalOrigin&&"function"==typeof t.connect&&"function"==typeof t.disconnect},localChanges:function(t){var e;return null!==(e=pu.get(t))&&void 0!==e?e:[]},applyRemoteEvents:function(t,e,n){t.applyRemoteEvents(e,n)},storeLocalChange:function(t,e){t.storeLocalChange(e)},flushLocalChanges:function(t){t.flushLocalChanges()},connected:function(t){return vu.has(t)},connect:function(t){t.connect()},disconnect:function(t){t.disconnect()},isLocal:function(t){return t.isLocalOrigin(gu.origin(t))},origin:function(t){var e=hu.get(t);return void 0!==e?e:t.localOrigin},withOrigin:function(t,e,n){var r=gu.origin(t);hu.set(t,e),n(),hu.set(t,r)},storePosition:function(t,e,n){var r=t.sharedRoot,o=t.positionStorageOrigin;Qa(r);var i=tu(r,t,n);r.doc.transact((function(){nu(r,e,i)}),o)},removeStoredPosition:function(t,e){var n=t.sharedRoot,r=t.positionStorageOrigin;Qa(n),n.doc.transact((function(){!function(t,e){t.removeAttribute(Za+e)}(n,e)}),r)},position:function(t,e){var n=function(t,e){var n=t.getAttribute(Za+e);return n?i.decodeRelativePosition(n):null}(t.sharedRoot,e);if(n)return eu(t.sharedRoot,t,n)},storedPositionsRelative:function(t){return e=t.sharedRoot,Object.fromEntries(Object.entries(e.getAttributes()).filter((function(t){return Li(t,1)[0].startsWith(Za)})).map((function(t){var e=Li(t,2),n=e[0],r=e[1];return[n.slice(Za.length),i.createRelativePositionFromJSON(r)]})));var e}};function yu(t,e){return void 0===e&&(e={}),function(n){var o,i,a=n;a.sharedRoot=t,a.localOrigin=null!==(o=e.localOrigin)&&void 0!==o?o:lu,a.positionStorageOrigin=null!==(i=e.positionStorageOrigin)&&void 0!==i?i:du,a.applyRemoteEvents=function(t,e){gu.flushLocalChanges(a),r.withoutNormalizing(a,(function(){gu.withOrigin(a,e,(function(){La(a.sharedRoot,a,t)}))}))},a.isLocalOrigin=function(t){return t===a.localOrigin};var u=function(t,e){a.isLocalOrigin(e.origin)||gu.applyRemoteEvents(a,t,e.origin)},c=null;e.autoConnect&&(c=setTimeout((function(){c=null,gu.connect(a)}))),a.connect=function(){if(gu.connected(a))throw new Error("already connected");a.sharedRoot.observeDeep(u);var t=ga(a.sharedRoot);a.children=t.children,vu.add(a),r.normalize(n,{force:!0}),n.operations.length||n.onChange()},a.disconnect=function(){c&&clearTimeout(c),gu.flushLocalChanges(a),a.sharedRoot.unobserveDeep(u),vu.delete(a)},a.storeLocalChange=function(t){pu.set(a,_i(_i([],Li(gu.localChanges(a))),[{op:t,doc:n.children,origin:gu.origin(a)}]))},a.flushLocalChanges=function(){Qa(a.sharedRoot);var t=gu.localChanges(a);pu.delete(a);var e=[];t.forEach((function(t){var n=e[e.length-1];if(n&&n[0].origin===t.origin)return n.push(t);e.push([t])})),e.forEach((function(t){Qa(a.sharedRoot),a.sharedRoot.doc.transact((function(){t.forEach((function(t){Qa(a.sharedRoot),function(t,e,n){var r=fu[n.type];if(!r)throw new Error("Unknown operation: "+n.type);r(t,e,n)}(a.sharedRoot,{children:t.doc},t.op)}))}),t[0].origin)}))};var s=a.apply,f=a.onChange;return a.apply=function(t){gu.connected(a)&&gu.isLocal(a)&&gu.storeLocalChange(a,t),s(t)},a.onChange=function(){gu.connected(a)&&gu.flushLocalChanges(a),f()},a}}var bu=bt("species"),mu=Mt.f,wu=To.fastKey,Ou=te.set,Su=te.getterFor,xu={getConstructor:function(t,e,n,r){var o=t((function(t,o){Wo(t,i),Ou(t,{type:e,index:cn(null),first:void 0,last:void 0,size:0}),h||(t.size=0),null!=o&&zo(o,t[r],{that:t,AS_ENTRIES:n})})),i=o.prototype,a=Su(e),u=function(t,e,n){var r,o,i=a(t),u=c(t,e);return u?u.value=n:(i.last=u={index:o=wu(e,!0),key:e,value:n,previous:r=i.last,next:void 0,removed:!1},i.first||(i.first=u),r&&(r.next=u),h?i.size++:t.size++,"F"!==o&&(i.index[o]=u)),t},c=function(t,e){var n,r=a(t),o=wu(e);if("F"!==o)return r.index[o];for(n=r.first;n;n=n.next)if(n.key==e)return n};return Oo(i,{clear:function(){for(var t=a(this),e=t.index,n=t.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete e[n.index],n=n.next;t.first=t.last=void 0,h?t.size=0:this.size=0},delete:function(t){var e=this,n=a(e),r=c(e,t);if(r){var o=r.next,i=r.previous;delete n.index[r.index],r.removed=!0,i&&(i.next=o),o&&(o.previous=i),n.first==r&&(n.first=o),n.last==r&&(n.last=i),h?n.size--:e.size--}return!!r},forEach:function(t){for(var e,n=a(this),r=En(t,arguments.length>1?arguments[1]:void 0);e=e?e.next:n.first;)for(r(e.value,e.key,this);e&&e.removed;)e=e.previous},has:function(t){return!!c(this,t)}}),Oo(i,n?{get:function(t){var e=c(this,t);return e&&e.value},set:function(t,e){return u(this,0===t?0:t,e)}}:{add:function(t){return u(this,t=0===t?0:t,t)}}),h&&mu(i,"size",{get:function(){return a(this).size}}),o},setStrong:function(t,e,n){var r=e+" Iterator",o=Su(e),i=Su(r);ao(t,e,(function(t,e){Ou(this,{type:r,target:t,state:o(t),kind:e,last:void 0})}),(function(){for(var t=i(this),e=t.kind,n=t.last;n&&n.removed;)n=n.previous;return t.target&&(t.last=n=n?n.next:t.state.first)?"keys"==e?{value:n.key,done:!1}:"values"==e?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(t.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),function(t){var e=D(t),n=Mt.f;h&&e&&!e[bu]&&n(e,bu,{configurable:!0,get:function(){return this}})}(e)}};Vo("Set",(function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}}),xu);var Eu=new WeakMap,ju=Symbol("slate-yjs-history-without-saving"),Tu={isYHistoryEditor:function(t){return gu.isYjsEditor(t)&&t.undoManager instanceof i.UndoManager&&"function"==typeof t.undo&&"function"==typeof t.redo&&"withoutSavingOrigin"in t},canUndo:function(t){return t.undoManager.undoStack.length>0},canRedo:function(t){return t.undoManager.redoStack.length>0},isSaving:function(t){return t.undoManager.trackedOrigins.has(gu.origin(t))},withoutSaving:function(t,e){gu.withOrigin(t,t.withoutSavingOrigin,e)}};function Pu(t){return void 0===t&&(t={}),function(e){var n=e,r=t.withoutSavingOrigin,a=void 0===r?ju:r,u=t.trackedOrigins,c=void 0===u?new Set([n.localOrigin]):u,s=ki(t,["withoutSavingOrigin","trackedOrigins"]),f=new i.UndoManager(n.sharedRoot,Ai({trackedOrigins:c},s));n.undoManager=f,n.withoutSavingOrigin=a;var l=n.onChange,d=n.isLocalOrigin;n.onChange=function(){l(),Eu.set(n,n.selection&&uu(n.sharedRoot,n,n.selection))},n.isLocalOrigin=function(t){return t===n.withoutSavingOrigin||d(t)};var h=function(t){var e=t.stackItem;e.meta.set("selection",n.selection&&uu(n.sharedRoot,n,n.selection)),e.meta.set("selectionBefore",Eu.get(n))},p=function(t){t.stackItem.meta.set("selection",n.selection&&uu(n.sharedRoot,n,n.selection))},v=function(t){var e=t.stackItem,r="undo"===t.type?n.undoManager.redoStack:n.undoManager.undoStack,i=r[r.length-1];i&&(i.meta.set("selection",e.meta.get("selectionBefore")),i.meta.set("selectionBefore",e.meta.get("selection")));var a=e.meta.get("selectionBefore");if(a){var u=cu(n.sharedRoot,n,a);u&&o.select(n,u)}},g=n.connect,y=n.disconnect;return n.connect=function(){g(),n.undoManager.on("stack-item-added",h),n.undoManager.on("stack-item-popped",v),n.undoManager.on("stack-item-updated",p)},n.disconnect=function(){n.undoManager.off("stack-item-added",h),n.undoManager.off("stack-item-popped",v),n.undoManager.off("stack-item-updated",p),y()},n.undo=function(){gu.connected(n)&&(gu.flushLocalChanges(n),n.undoManager.undo())},n.redo=function(){gu.connected(n)&&(gu.flushLocalChanges(n),n.undoManager.redo())},n}}var Ru=new WeakMap,Au={isCursorEditor:function(t){return gu.isYjsEditor(t)&&t.awareness&&"string"==typeof t.cursorDataField&&"string"==typeof t.selectionStateField&&"function"==typeof t.sendCursorPosition&&"function"==typeof t.sendCursorData},sendCursorPosition:function(t,e){void 0===e&&(e=t.selection),t.sendCursorPosition(e)},sendCursorData:function(t,e){t.sendCursorData(e)},on:function(t,e,n){var r;if("change"===e){var o=null!==(r=Ru.get(t))&&void 0!==r?r:new Set;o.add(n),t&&Ru.set(t,o)}},off:function(t,e,n){if("change"===e){var r=Ru.get(t);r&&r.delete(n)}},cursorState:function(t,e){var n;if(e===t.awareness.clientID||!gu.connected(t))return null;var r=t.awareness.getStates().get(e);return r?{relativeSelection:null!==(n=r[t.selectionStateField])&&void 0!==n?n:null,data:r[t.cursorDataField],clientId:e}:null},cursorStates:function(t){return gu.connected(t)?Object.fromEntries(Array.from(t.awareness.getStates().entries(),(function(e){var n=Li(e,2),r=n[0],o=n[1];return r!==t.awareness.clientID&&o?[r,{relativeSelection:o[t.selectionStateField],data:o[t.cursorDataField]}]:null})).filter(Array.isArray)):{}}};function ku(t,e){return void 0===e&&(e={}),function(n){var r=e.cursorStateField,o=void 0===r?"selection":r,a=e.cursorDataField,u=void 0===a?"data":a,c=e.autoSend,s=void 0===c||c,f=e.data,l=n;l.awareness=t,l.cursorDataField=u,l.selectionStateField=o,l.sendCursorData=function(t){l.awareness.setLocalStateField(l.cursorDataField,t)},l.sendCursorPosition=function(t){var e=l.awareness.getLocalState(),n=null==e?void 0:e[o];if(t){var r=uu(l.sharedRoot,l,t),a=r.anchor,u=r.focus;n&&i.compareRelativePositions(a,n)&&i.compareRelativePositions(u,n)||l.awareness.setLocalStateField(l.selectionStateField,{anchor:a,focus:u})}else n&&l.awareness.setLocalStateField(l.selectionStateField,null)};var d=function(t){var e=Ru.get(l);if(e){var n=l.awareness.clientID,r={added:t.added.filter((function(t){return t!==n})),removed:t.removed.filter((function(t){return t!==n})),updated:t.updated.filter((function(t){return t!==n}))};(r.added.length>0||r.removed.length>0||r.updated.length>0)&&e.forEach((function(t){return t(r)}))}},h=l.connect,p=l.disconnect;return l.connect=function(){if(h(),l.awareness.on("change",d),d({removed:[],added:Array.from(l.awareness.getStates().keys()),updated:[]}),s){f&&Au.sendCursorData(l,f);var t=l.onChange;l.onChange=function(){t(),gu.connected(l)&&Au.sendCursorPosition(l)}}},l.disconnect=function(){l.awareness.off("change",d),d({removed:Array.from(l.awareness.getStates().keys()),added:[],updated:[]}),p()},l}}export{Au as CursorEditor,Tu as YHistoryEditor,gu as YjsEditor,eu as relativePositionToSlatePoint,cu as relativeRangeToSlateRange,ba as slateNodesToInsertDelta,tu as slatePointToRelativePosition,uu as slateRangeToRelativeRange,ku as withCursors,Pu as withYHistory,yu as withYjs,ga as yTextToSlateElement};
|
|
2
|
-
|
|
1
|
+
import { Text, Node, Path, Editor, Transforms } from 'slate'
|
|
2
|
+
import * as Y from 'yjs'
|
|
3
|
+
|
|
4
|
+
/******************************************************************************
|
|
5
|
+
Copyright (c) Microsoft Corporation.
|
|
6
|
+
|
|
7
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
8
|
+
purpose with or without fee is hereby granted.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
11
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
12
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
13
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
14
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
15
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
16
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
17
|
+
***************************************************************************** */
|
|
18
|
+
|
|
19
|
+
var __assign = function () {
|
|
20
|
+
__assign =
|
|
21
|
+
Object.assign ||
|
|
22
|
+
function __assign(t) {
|
|
23
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24
|
+
s = arguments[i]
|
|
25
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]
|
|
26
|
+
}
|
|
27
|
+
return t
|
|
28
|
+
}
|
|
29
|
+
return __assign.apply(this, arguments)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function __rest(s, e) {
|
|
33
|
+
var t = {}
|
|
34
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]
|
|
35
|
+
if (s != null && typeof Object.getOwnPropertySymbols === 'function')
|
|
36
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
37
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
38
|
+
t[p[i]] = s[p[i]]
|
|
39
|
+
}
|
|
40
|
+
return t
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function __values(o) {
|
|
44
|
+
var s = typeof Symbol === 'function' && Symbol.iterator,
|
|
45
|
+
m = s && o[s],
|
|
46
|
+
i = 0
|
|
47
|
+
if (m) return m.call(o)
|
|
48
|
+
if (o && typeof o.length === 'number')
|
|
49
|
+
return {
|
|
50
|
+
next: function () {
|
|
51
|
+
if (o && i >= o.length) o = void 0
|
|
52
|
+
return { value: o && o[i++], done: !o }
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
throw new TypeError(s ? 'Object is not iterable.' : 'Symbol.iterator is not defined.')
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function __read(o, n) {
|
|
59
|
+
var m = typeof Symbol === 'function' && o[Symbol.iterator]
|
|
60
|
+
if (!m) return o
|
|
61
|
+
var i = m.call(o),
|
|
62
|
+
r,
|
|
63
|
+
ar = [],
|
|
64
|
+
e
|
|
65
|
+
try {
|
|
66
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value)
|
|
67
|
+
} catch (error) {
|
|
68
|
+
e = { error: error }
|
|
69
|
+
} finally {
|
|
70
|
+
try {
|
|
71
|
+
if (r && !r.done && (m = i['return'])) m.call(i)
|
|
72
|
+
} finally {
|
|
73
|
+
if (e) throw e.error
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return ar
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function __spreadArray(to, from, pack) {
|
|
80
|
+
if (pack || arguments.length === 2)
|
|
81
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
82
|
+
if (ar || !(i in from)) {
|
|
83
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i)
|
|
84
|
+
ar[i] = from[i]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return to.concat(ar || Array.prototype.slice.call(from))
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
typeof SuppressedError === 'function'
|
|
91
|
+
? SuppressedError
|
|
92
|
+
: function (error, suppressed, message) {
|
|
93
|
+
var e = new Error(message)
|
|
94
|
+
return (e.name = 'SuppressedError'), (e.error = error), (e.suppressed = suppressed), e
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function isObject(o) {
|
|
98
|
+
return Object.prototype.toString.call(o) === '[object Object]'
|
|
99
|
+
}
|
|
100
|
+
function isPlainObject(o) {
|
|
101
|
+
if (!isObject(o)) {
|
|
102
|
+
return false
|
|
103
|
+
}
|
|
104
|
+
// If has modified constructor
|
|
105
|
+
var ctor = o.constructor
|
|
106
|
+
if (ctor === undefined) {
|
|
107
|
+
return true
|
|
108
|
+
}
|
|
109
|
+
// If has modified prototype
|
|
110
|
+
var prot = ctor.prototype
|
|
111
|
+
if (isObject(prot) === false) {
|
|
112
|
+
return false
|
|
113
|
+
}
|
|
114
|
+
// If constructor does not have an Object-specific method
|
|
115
|
+
if (Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOfOf')) {
|
|
116
|
+
return false
|
|
117
|
+
}
|
|
118
|
+
// Most likely a plain Object
|
|
119
|
+
return true
|
|
120
|
+
}
|
|
121
|
+
// Slates deep equality function: https://github.com/ianstormtaylor/slate/blob/68aff89e892fe15a16314398ff052ade6068900b/packages/slate/src/utils/deep-equal.ts#L13
|
|
122
|
+
// We have to match slates deepEquals behavior to merge insert deltas in the same way slate does.
|
|
123
|
+
function deepEquals(node, another) {
|
|
124
|
+
// eslint-disable-next-line guard-for-in
|
|
125
|
+
for (var key in node) {
|
|
126
|
+
var a = node[key]
|
|
127
|
+
var b = another[key]
|
|
128
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
129
|
+
if (!deepEquals(a, b)) {
|
|
130
|
+
return false
|
|
131
|
+
}
|
|
132
|
+
} else if (Array.isArray(a) && Array.isArray(b)) {
|
|
133
|
+
if (a.length !== b.length) return false
|
|
134
|
+
for (var i = 0; i < a.length; i++) {
|
|
135
|
+
if (a[i] !== b[i]) {
|
|
136
|
+
return false
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
} else if (a !== b) {
|
|
140
|
+
return false
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
for (var key in another) {
|
|
144
|
+
if (node[key] === undefined && another[key] !== undefined) {
|
|
145
|
+
return false
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return true
|
|
149
|
+
}
|
|
150
|
+
function pick(obj) {
|
|
151
|
+
var keys = []
|
|
152
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
153
|
+
keys[_i - 1] = arguments[_i]
|
|
154
|
+
}
|
|
155
|
+
return Object.fromEntries(
|
|
156
|
+
Object.entries(obj).filter(function (_a) {
|
|
157
|
+
var _b = __read(_a, 1),
|
|
158
|
+
key = _b[0]
|
|
159
|
+
return keys.includes(key)
|
|
160
|
+
})
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
function omit(obj) {
|
|
164
|
+
var keys = []
|
|
165
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
166
|
+
keys[_i - 1] = arguments[_i]
|
|
167
|
+
}
|
|
168
|
+
return Object.fromEntries(
|
|
169
|
+
Object.entries(obj).filter(function (_a) {
|
|
170
|
+
var _b = __read(_a, 1),
|
|
171
|
+
key = _b[0]
|
|
172
|
+
return !keys.includes(key)
|
|
173
|
+
})
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
function omitNullEntries(obj) {
|
|
177
|
+
return Object.fromEntries(
|
|
178
|
+
Object.entries(obj).filter(function (_a) {
|
|
179
|
+
var _b = __read(_a, 2),
|
|
180
|
+
value = _b[1]
|
|
181
|
+
return value !== null
|
|
182
|
+
})
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function normalizeInsertDelta(delta) {
|
|
187
|
+
var e_1, _a
|
|
188
|
+
var _b, _c
|
|
189
|
+
var normalized = []
|
|
190
|
+
try {
|
|
191
|
+
for (
|
|
192
|
+
var delta_1 = __values(delta), delta_1_1 = delta_1.next();
|
|
193
|
+
!delta_1_1.done;
|
|
194
|
+
delta_1_1 = delta_1.next()
|
|
195
|
+
) {
|
|
196
|
+
var element = delta_1_1.value
|
|
197
|
+
if (typeof element.insert === 'string' && element.insert.length === 0) {
|
|
198
|
+
continue
|
|
199
|
+
}
|
|
200
|
+
var prev = normalized[normalized.length - 1]
|
|
201
|
+
if (!prev || typeof prev.insert !== 'string' || typeof element.insert !== 'string') {
|
|
202
|
+
normalized.push(element)
|
|
203
|
+
continue
|
|
204
|
+
}
|
|
205
|
+
var merge =
|
|
206
|
+
prev.attributes === element.attributes ||
|
|
207
|
+
(!prev.attributes === !element.attributes &&
|
|
208
|
+
deepEquals(
|
|
209
|
+
(_b = prev.attributes) !== null && _b !== void 0 ? _b : {},
|
|
210
|
+
(_c = element.attributes) !== null && _c !== void 0 ? _c : {}
|
|
211
|
+
))
|
|
212
|
+
if (merge) {
|
|
213
|
+
prev.insert += element.insert
|
|
214
|
+
continue
|
|
215
|
+
}
|
|
216
|
+
normalized.push(element)
|
|
217
|
+
}
|
|
218
|
+
} catch (e_1_1) {
|
|
219
|
+
e_1 = { error: e_1_1 }
|
|
220
|
+
} finally {
|
|
221
|
+
try {
|
|
222
|
+
if (delta_1_1 && !delta_1_1.done && (_a = delta_1.return)) _a.call(delta_1)
|
|
223
|
+
} finally {
|
|
224
|
+
if (e_1) throw e_1.error
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return normalized
|
|
228
|
+
}
|
|
229
|
+
function yTextToInsertDelta(yText) {
|
|
230
|
+
return normalizeInsertDelta(yText.toDelta())
|
|
231
|
+
}
|
|
232
|
+
function getInsertLength(_a) {
|
|
233
|
+
var insert = _a.insert
|
|
234
|
+
return typeof insert === 'string' ? insert.length : 1
|
|
235
|
+
}
|
|
236
|
+
function getInsertDeltaLength(delta) {
|
|
237
|
+
return delta.reduce(function (curr, element) {
|
|
238
|
+
return curr + getInsertLength(element)
|
|
239
|
+
}, 0)
|
|
240
|
+
}
|
|
241
|
+
function sliceInsertDelta(delta, start, length) {
|
|
242
|
+
if (length < 1) {
|
|
243
|
+
return []
|
|
244
|
+
}
|
|
245
|
+
var currentOffset = 0
|
|
246
|
+
var sliced = []
|
|
247
|
+
var end = start + length
|
|
248
|
+
for (var i = 0; i < delta.length; i++) {
|
|
249
|
+
if (currentOffset >= end) {
|
|
250
|
+
break
|
|
251
|
+
}
|
|
252
|
+
var element = delta[i]
|
|
253
|
+
var elementLength = getInsertLength(element)
|
|
254
|
+
if (currentOffset + elementLength <= start) {
|
|
255
|
+
currentOffset += elementLength
|
|
256
|
+
continue
|
|
257
|
+
}
|
|
258
|
+
if (typeof element.insert !== 'string') {
|
|
259
|
+
currentOffset += elementLength
|
|
260
|
+
sliced.push(element)
|
|
261
|
+
continue
|
|
262
|
+
}
|
|
263
|
+
var startOffset = Math.max(0, start - currentOffset)
|
|
264
|
+
var endOffset = Math.min(elementLength, elementLength - (currentOffset + elementLength - end))
|
|
265
|
+
sliced.push(
|
|
266
|
+
__assign(__assign({}, element), { insert: element.insert.slice(startOffset, endOffset) })
|
|
267
|
+
)
|
|
268
|
+
currentOffset += elementLength
|
|
269
|
+
}
|
|
270
|
+
return sliced
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function getProperties(node) {
|
|
274
|
+
return omit(node, Text.isText(node) ? 'text' : 'children')
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function yTextToSlateElement(yText) {
|
|
278
|
+
var delta = yTextToInsertDelta(yText)
|
|
279
|
+
var children = delta.length > 0 ? delta.map(deltaInsertToSlateNode) : [{ text: '' }]
|
|
280
|
+
return __assign(__assign({}, yText.getAttributes()), { children: children })
|
|
281
|
+
}
|
|
282
|
+
function deltaInsertToSlateNode(insert) {
|
|
283
|
+
if (typeof insert.insert === 'string') {
|
|
284
|
+
return __assign(__assign({}, insert.attributes), { text: insert.insert })
|
|
285
|
+
}
|
|
286
|
+
return yTextToSlateElement(insert.insert)
|
|
287
|
+
}
|
|
288
|
+
function slateNodesToInsertDelta(nodes) {
|
|
289
|
+
return nodes.map(function (node) {
|
|
290
|
+
if (Text.isText(node)) {
|
|
291
|
+
return { insert: node.text, attributes: getProperties(node) }
|
|
292
|
+
}
|
|
293
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
294
|
+
return { insert: slateElementToYText(node) }
|
|
295
|
+
})
|
|
296
|
+
}
|
|
297
|
+
function slateElementToYText(_a) {
|
|
298
|
+
var children = _a.children,
|
|
299
|
+
attributes = __rest(_a, ['children'])
|
|
300
|
+
var yElement = new Y.XmlText()
|
|
301
|
+
Object.entries(attributes).forEach(function (_a) {
|
|
302
|
+
var _b = __read(_a, 2),
|
|
303
|
+
key = _b[0],
|
|
304
|
+
value = _b[1]
|
|
305
|
+
yElement.setAttribute(key, value)
|
|
306
|
+
})
|
|
307
|
+
yElement.applyDelta(slateNodesToInsertDelta(children), { sanitize: false })
|
|
308
|
+
return yElement
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function getSlateNodeYLength(node) {
|
|
312
|
+
if (!node) {
|
|
313
|
+
return 0
|
|
314
|
+
}
|
|
315
|
+
return Text.isText(node) ? node.text.length : 1
|
|
316
|
+
}
|
|
317
|
+
function slatePathOffsetToYOffset(element, pathOffset) {
|
|
318
|
+
return element.children.slice(0, pathOffset).reduce(function (yOffset, node) {
|
|
319
|
+
return yOffset + getSlateNodeYLength(node)
|
|
320
|
+
}, 0)
|
|
321
|
+
}
|
|
322
|
+
function getYTarget(yRoot, slateRoot, path) {
|
|
323
|
+
var _a
|
|
324
|
+
if (path.length === 0) {
|
|
325
|
+
throw new Error('Path has to a have a length >= 1')
|
|
326
|
+
}
|
|
327
|
+
if (Text.isText(slateRoot)) {
|
|
328
|
+
throw new Error('Cannot descent into slate text')
|
|
329
|
+
}
|
|
330
|
+
var _b = __read(path),
|
|
331
|
+
pathOffset = _b[0],
|
|
332
|
+
childPath = _b.slice(1)
|
|
333
|
+
var yOffset = slatePathOffsetToYOffset(slateRoot, pathOffset)
|
|
334
|
+
var targetNode = slateRoot.children[pathOffset]
|
|
335
|
+
var delta = yTextToInsertDelta(yRoot)
|
|
336
|
+
var targetLength = getSlateNodeYLength(targetNode)
|
|
337
|
+
var targetDelta = sliceInsertDelta(delta, yOffset, targetLength)
|
|
338
|
+
if (targetDelta.length > 1) {
|
|
339
|
+
throw new Error("Path doesn't match yText, yTarget spans multiple nodes")
|
|
340
|
+
}
|
|
341
|
+
var yTarget = (_a = targetDelta[0]) === null || _a === void 0 ? void 0 : _a.insert
|
|
342
|
+
if (childPath.length > 0) {
|
|
343
|
+
if (!(yTarget instanceof Y.XmlText)) {
|
|
344
|
+
throw new Error("Path doesn't match yText, cannot descent into non-yText")
|
|
345
|
+
}
|
|
346
|
+
return getYTarget(yTarget, targetNode, childPath)
|
|
347
|
+
}
|
|
348
|
+
return {
|
|
349
|
+
yParent: yRoot,
|
|
350
|
+
textRange: { start: yOffset, end: yOffset + targetLength },
|
|
351
|
+
yTarget: yTarget instanceof Y.XmlText ? yTarget : undefined,
|
|
352
|
+
slateParent: slateRoot,
|
|
353
|
+
slateTarget: targetNode,
|
|
354
|
+
targetDelta: targetDelta,
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function yOffsetToSlateOffsets(parent, yOffset, opts) {
|
|
358
|
+
if (opts === void 0) {
|
|
359
|
+
opts = {}
|
|
360
|
+
}
|
|
361
|
+
var _a = opts.assoc,
|
|
362
|
+
assoc = _a === void 0 ? 0 : _a,
|
|
363
|
+
_b = opts.insert,
|
|
364
|
+
insert = _b === void 0 ? false : _b
|
|
365
|
+
var currentOffset = 0
|
|
366
|
+
var lastNonEmptyPathOffset = 0
|
|
367
|
+
for (var pathOffset = 0; pathOffset < parent.children.length; pathOffset++) {
|
|
368
|
+
var child_1 = parent.children[pathOffset]
|
|
369
|
+
var nodeLength = Text.isText(child_1) ? child_1.text.length : 1
|
|
370
|
+
if (nodeLength > 0) {
|
|
371
|
+
lastNonEmptyPathOffset = pathOffset
|
|
372
|
+
}
|
|
373
|
+
var endOffset = currentOffset + nodeLength
|
|
374
|
+
if (nodeLength > 0 && (assoc >= 0 ? endOffset > yOffset : endOffset >= yOffset)) {
|
|
375
|
+
return [pathOffset, yOffset - currentOffset]
|
|
376
|
+
}
|
|
377
|
+
currentOffset += nodeLength
|
|
378
|
+
}
|
|
379
|
+
if (yOffset > currentOffset + (insert ? 1 : 0)) {
|
|
380
|
+
throw new Error('yOffset out of bounds')
|
|
381
|
+
}
|
|
382
|
+
if (insert) {
|
|
383
|
+
return [parent.children.length, 0]
|
|
384
|
+
}
|
|
385
|
+
var child = parent.children[lastNonEmptyPathOffset]
|
|
386
|
+
var textOffset = Text.isText(child) ? child.text.length : 1
|
|
387
|
+
return [lastNonEmptyPathOffset, textOffset]
|
|
388
|
+
}
|
|
389
|
+
function getSlatePath(sharedRoot, slateRoot, yText) {
|
|
390
|
+
var yNodePath = [yText]
|
|
391
|
+
while (yNodePath[0] !== sharedRoot) {
|
|
392
|
+
var yParent = yNodePath[0].parent
|
|
393
|
+
if (!yParent) {
|
|
394
|
+
throw new Error("yText isn't a descendant of root element")
|
|
395
|
+
}
|
|
396
|
+
if (!(yParent instanceof Y.XmlText)) {
|
|
397
|
+
throw new Error('Unexpected y parent type')
|
|
398
|
+
}
|
|
399
|
+
yNodePath.unshift(yParent)
|
|
400
|
+
}
|
|
401
|
+
if (yNodePath.length < 2) {
|
|
402
|
+
return []
|
|
403
|
+
}
|
|
404
|
+
var slateParent = slateRoot
|
|
405
|
+
return yNodePath.reduce(function (path, yParent, idx) {
|
|
406
|
+
var e_1, _a
|
|
407
|
+
var yChild = yNodePath[idx + 1]
|
|
408
|
+
if (!yChild) {
|
|
409
|
+
return path
|
|
410
|
+
}
|
|
411
|
+
var yOffset = 0
|
|
412
|
+
var currentDelta = yTextToInsertDelta(yParent)
|
|
413
|
+
try {
|
|
414
|
+
for (
|
|
415
|
+
var currentDelta_1 = __values(currentDelta), currentDelta_1_1 = currentDelta_1.next();
|
|
416
|
+
!currentDelta_1_1.done;
|
|
417
|
+
currentDelta_1_1 = currentDelta_1.next()
|
|
418
|
+
) {
|
|
419
|
+
var element = currentDelta_1_1.value
|
|
420
|
+
if (element.insert === yChild) {
|
|
421
|
+
break
|
|
422
|
+
}
|
|
423
|
+
yOffset += typeof element.insert === 'string' ? element.insert.length : 1
|
|
424
|
+
}
|
|
425
|
+
} catch (e_1_1) {
|
|
426
|
+
e_1 = { error: e_1_1 }
|
|
427
|
+
} finally {
|
|
428
|
+
try {
|
|
429
|
+
if (currentDelta_1_1 && !currentDelta_1_1.done && (_a = currentDelta_1.return))
|
|
430
|
+
_a.call(currentDelta_1)
|
|
431
|
+
} finally {
|
|
432
|
+
if (e_1) throw e_1.error
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
if (Text.isText(slateParent)) {
|
|
436
|
+
throw new Error('Cannot descent into slate text')
|
|
437
|
+
}
|
|
438
|
+
var _b = __read(yOffsetToSlateOffsets(slateParent, yOffset), 1),
|
|
439
|
+
pathOffset = _b[0]
|
|
440
|
+
slateParent = slateParent.children[pathOffset]
|
|
441
|
+
return path.concat(pathOffset)
|
|
442
|
+
}, [])
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function applyDelta(node, slatePath, delta) {
|
|
446
|
+
var ops = []
|
|
447
|
+
var yOffset = delta.reduce(function (length, change) {
|
|
448
|
+
if ('retain' in change) {
|
|
449
|
+
return length + change.retain
|
|
450
|
+
}
|
|
451
|
+
if ('delete' in change) {
|
|
452
|
+
return length + change.delete
|
|
453
|
+
}
|
|
454
|
+
return length
|
|
455
|
+
}, 0)
|
|
456
|
+
// Apply changes in reverse order to avoid path changes.
|
|
457
|
+
delta.reverse().forEach(function (change) {
|
|
458
|
+
var _a
|
|
459
|
+
if ('attributes' in change && 'retain' in change) {
|
|
460
|
+
var _b = __read(yOffsetToSlateOffsets(node, yOffset - change.retain), 2),
|
|
461
|
+
startPathOffset = _b[0],
|
|
462
|
+
startTextOffset = _b[1]
|
|
463
|
+
var _c = __read(yOffsetToSlateOffsets(node, yOffset, { assoc: -1 }), 2),
|
|
464
|
+
endPathOffset = _c[0],
|
|
465
|
+
endTextOffset = _c[1]
|
|
466
|
+
for (var pathOffset = endPathOffset; pathOffset >= startPathOffset; pathOffset--) {
|
|
467
|
+
var child = node.children[pathOffset]
|
|
468
|
+
var childPath = __spreadArray(__spreadArray([], __read(slatePath)), [pathOffset])
|
|
469
|
+
if (!Text.isText(child)) {
|
|
470
|
+
// Ignore attribute updates on non-text nodes (which are backed by Y.XmlText)
|
|
471
|
+
// to be consistent with deltaInsertToSlateNode. Y.XmlText attributes don't show
|
|
472
|
+
// up in deltas but in key changes (YEvent.changes.keys).
|
|
473
|
+
continue
|
|
474
|
+
}
|
|
475
|
+
var newProperties = change.attributes
|
|
476
|
+
var properties = pick.apply(
|
|
477
|
+
void 0,
|
|
478
|
+
__spreadArray([node], __read(Object.keys(change.attributes)))
|
|
479
|
+
)
|
|
480
|
+
if (pathOffset === startPathOffset || pathOffset === endPathOffset) {
|
|
481
|
+
var start = pathOffset === startPathOffset ? startTextOffset : 0
|
|
482
|
+
var end = pathOffset === endPathOffset ? endTextOffset : child.text.length
|
|
483
|
+
if (end !== child.text.length) {
|
|
484
|
+
ops.push({
|
|
485
|
+
type: 'split_node',
|
|
486
|
+
path: childPath,
|
|
487
|
+
position: end,
|
|
488
|
+
properties: getProperties(child),
|
|
489
|
+
})
|
|
490
|
+
}
|
|
491
|
+
if (start !== 0) {
|
|
492
|
+
ops.push({
|
|
493
|
+
type: 'split_node',
|
|
494
|
+
path: childPath,
|
|
495
|
+
position: start,
|
|
496
|
+
properties: omitNullEntries(
|
|
497
|
+
__assign(__assign({}, getProperties(child)), newProperties)
|
|
498
|
+
),
|
|
499
|
+
})
|
|
500
|
+
continue
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
ops.push({
|
|
504
|
+
type: 'set_node',
|
|
505
|
+
newProperties: newProperties,
|
|
506
|
+
path: childPath,
|
|
507
|
+
properties: properties,
|
|
508
|
+
})
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
if ('retain' in change) {
|
|
512
|
+
yOffset -= change.retain
|
|
513
|
+
}
|
|
514
|
+
if ('delete' in change) {
|
|
515
|
+
var _d = __read(yOffsetToSlateOffsets(node, yOffset - change.delete), 2),
|
|
516
|
+
startPathOffset = _d[0],
|
|
517
|
+
startTextOffset = _d[1]
|
|
518
|
+
var _e = __read(yOffsetToSlateOffsets(node, yOffset, { assoc: -1 }), 2),
|
|
519
|
+
endPathOffset = _e[0],
|
|
520
|
+
endTextOffset = _e[1]
|
|
521
|
+
for (
|
|
522
|
+
var pathOffset = endTextOffset === 0 ? endPathOffset - 1 : endPathOffset;
|
|
523
|
+
pathOffset >= startPathOffset;
|
|
524
|
+
pathOffset--
|
|
525
|
+
) {
|
|
526
|
+
var child = node.children[pathOffset]
|
|
527
|
+
var childPath = __spreadArray(__spreadArray([], __read(slatePath)), [pathOffset])
|
|
528
|
+
if (
|
|
529
|
+
Text.isText(child) &&
|
|
530
|
+
(pathOffset === startPathOffset || pathOffset === endPathOffset)
|
|
531
|
+
) {
|
|
532
|
+
var start = pathOffset === startPathOffset ? startTextOffset : 0
|
|
533
|
+
var end = pathOffset === endPathOffset ? endTextOffset : child.text.length
|
|
534
|
+
ops.push({
|
|
535
|
+
type: 'remove_text',
|
|
536
|
+
offset: start,
|
|
537
|
+
text: child.text.slice(start, end),
|
|
538
|
+
path: childPath,
|
|
539
|
+
})
|
|
540
|
+
yOffset -= end - start
|
|
541
|
+
continue
|
|
542
|
+
}
|
|
543
|
+
ops.push({
|
|
544
|
+
type: 'remove_node',
|
|
545
|
+
node: child,
|
|
546
|
+
path: childPath,
|
|
547
|
+
})
|
|
548
|
+
yOffset -= getSlateNodeYLength(child)
|
|
549
|
+
}
|
|
550
|
+
return
|
|
551
|
+
}
|
|
552
|
+
if ('insert' in change) {
|
|
553
|
+
var _f = __read(
|
|
554
|
+
yOffsetToSlateOffsets(node, yOffset, {
|
|
555
|
+
insert: true,
|
|
556
|
+
}),
|
|
557
|
+
2
|
|
558
|
+
),
|
|
559
|
+
pathOffset = _f[0],
|
|
560
|
+
textOffset = _f[1]
|
|
561
|
+
var child = node.children[pathOffset]
|
|
562
|
+
var childPath = __spreadArray(__spreadArray([], __read(slatePath)), [pathOffset])
|
|
563
|
+
if (Text.isText(child)) {
|
|
564
|
+
var lastOp = ops[ops.length - 1]
|
|
565
|
+
/**
|
|
566
|
+
* The props that exist at the current path
|
|
567
|
+
* Since we're not actually using slate to update the node
|
|
568
|
+
* this is a simulation
|
|
569
|
+
*/
|
|
570
|
+
var currentProps =
|
|
571
|
+
lastOp != null && lastOp.type === 'insert_node' ? lastOp.node : getProperties(child)
|
|
572
|
+
var lastPath = []
|
|
573
|
+
if (
|
|
574
|
+
lastOp != null &&
|
|
575
|
+
(lastOp.type === 'insert_node' ||
|
|
576
|
+
lastOp.type === 'insert_text' ||
|
|
577
|
+
lastOp.type === 'split_node' ||
|
|
578
|
+
lastOp.type === 'set_node')
|
|
579
|
+
) {
|
|
580
|
+
lastPath = lastOp.path
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* If the insert is a string and the attributes are the same as the
|
|
584
|
+
* props at the current path, we can just insert a text node
|
|
585
|
+
*/
|
|
586
|
+
if (
|
|
587
|
+
typeof change.insert === 'string' &&
|
|
588
|
+
deepEquals((_a = change.attributes) !== null && _a !== void 0 ? _a : {}, currentProps) &&
|
|
589
|
+
Path.equals(childPath, lastPath)
|
|
590
|
+
) {
|
|
591
|
+
return ops.push({
|
|
592
|
+
type: 'insert_text',
|
|
593
|
+
offset: textOffset,
|
|
594
|
+
text: change.insert,
|
|
595
|
+
path: childPath,
|
|
596
|
+
})
|
|
597
|
+
}
|
|
598
|
+
var toInsert = deltaInsertToSlateNode(change)
|
|
599
|
+
if (textOffset === 0) {
|
|
600
|
+
return ops.push({
|
|
601
|
+
type: 'insert_node',
|
|
602
|
+
path: childPath,
|
|
603
|
+
node: toInsert,
|
|
604
|
+
})
|
|
605
|
+
}
|
|
606
|
+
if (textOffset < child.text.length) {
|
|
607
|
+
ops.push({
|
|
608
|
+
type: 'split_node',
|
|
609
|
+
path: childPath,
|
|
610
|
+
position: textOffset,
|
|
611
|
+
properties: getProperties(child),
|
|
612
|
+
})
|
|
613
|
+
}
|
|
614
|
+
return ops.push({
|
|
615
|
+
type: 'insert_node',
|
|
616
|
+
path: Path.next(childPath),
|
|
617
|
+
node: toInsert,
|
|
618
|
+
})
|
|
619
|
+
}
|
|
620
|
+
return ops.push({
|
|
621
|
+
type: 'insert_node',
|
|
622
|
+
path: childPath,
|
|
623
|
+
node: deltaInsertToSlateNode(change),
|
|
624
|
+
})
|
|
625
|
+
}
|
|
626
|
+
})
|
|
627
|
+
return ops
|
|
628
|
+
}
|
|
629
|
+
function translateYTextEvent(sharedRoot, editor, event) {
|
|
630
|
+
var target = event.target,
|
|
631
|
+
changes = event.changes
|
|
632
|
+
var delta = event.delta
|
|
633
|
+
if (!(target instanceof Y.XmlText)) {
|
|
634
|
+
throw new Error('Unexpected target node type')
|
|
635
|
+
}
|
|
636
|
+
var ops = []
|
|
637
|
+
var slatePath = getSlatePath(sharedRoot, editor, target)
|
|
638
|
+
var targetElement = Node.get(editor, slatePath)
|
|
639
|
+
if (Text.isText(targetElement)) {
|
|
640
|
+
throw new Error('Cannot apply yTextEvent to text node')
|
|
641
|
+
}
|
|
642
|
+
var keyChanges = Array.from(changes.keys.entries())
|
|
643
|
+
if (slatePath.length > 0 && keyChanges.length > 0) {
|
|
644
|
+
var newProperties = Object.fromEntries(
|
|
645
|
+
keyChanges.map(function (_a) {
|
|
646
|
+
var _b = __read(_a, 2),
|
|
647
|
+
key = _b[0],
|
|
648
|
+
info = _b[1]
|
|
649
|
+
return [key, info.action === 'delete' ? null : target.getAttribute(key)]
|
|
650
|
+
})
|
|
651
|
+
)
|
|
652
|
+
var properties = Object.fromEntries(
|
|
653
|
+
keyChanges.map(function (_a) {
|
|
654
|
+
var _b = __read(_a, 1),
|
|
655
|
+
key = _b[0]
|
|
656
|
+
return [key, targetElement[key]]
|
|
657
|
+
})
|
|
658
|
+
)
|
|
659
|
+
ops.push({
|
|
660
|
+
type: 'set_node',
|
|
661
|
+
newProperties: newProperties,
|
|
662
|
+
properties: properties,
|
|
663
|
+
path: slatePath,
|
|
664
|
+
})
|
|
665
|
+
}
|
|
666
|
+
if (delta.length > 0) {
|
|
667
|
+
ops.push.apply(ops, __spreadArray([], __read(applyDelta(targetElement, slatePath, delta))))
|
|
668
|
+
}
|
|
669
|
+
return ops
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Translate a yjs event into slate operations. The editor state has to match the
|
|
674
|
+
* yText state before the event occurred.
|
|
675
|
+
*
|
|
676
|
+
* @param sharedType
|
|
677
|
+
* @param op
|
|
678
|
+
*/
|
|
679
|
+
function translateYjsEvent(sharedRoot, editor, event) {
|
|
680
|
+
if (event instanceof Y.YTextEvent) {
|
|
681
|
+
return translateYTextEvent(sharedRoot, editor, event)
|
|
682
|
+
}
|
|
683
|
+
throw new Error('Unexpected Y event type')
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Translates yjs events into slate operations and applies them to the editor. The
|
|
687
|
+
* editor state has to match the yText state before the events occurred.
|
|
688
|
+
*
|
|
689
|
+
* @param sharedRoot
|
|
690
|
+
* @param editor
|
|
691
|
+
* @param events
|
|
692
|
+
*/
|
|
693
|
+
function applyYjsEvents(sharedRoot, editor, events) {
|
|
694
|
+
Editor.withoutNormalizing(editor, function () {
|
|
695
|
+
events.forEach(function (event) {
|
|
696
|
+
translateYjsEvent(sharedRoot, editor, event).forEach(function (op) {
|
|
697
|
+
editor.apply(op)
|
|
698
|
+
})
|
|
699
|
+
})
|
|
700
|
+
})
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
function insertNode(sharedRoot, slateRoot, op) {
|
|
704
|
+
var _a = getYTarget(sharedRoot, slateRoot, op.path),
|
|
705
|
+
yParent = _a.yParent,
|
|
706
|
+
textRange = _a.textRange
|
|
707
|
+
if (Text.isText(op.node)) {
|
|
708
|
+
return yParent.insert(textRange.start, op.node.text, getProperties(op.node))
|
|
709
|
+
}
|
|
710
|
+
yParent.insertEmbed(textRange.start, slateElementToYText(op.node))
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
function cloneInsertDeltaDeep(delta) {
|
|
714
|
+
return delta.map(function (element) {
|
|
715
|
+
if (typeof element.insert === 'string') {
|
|
716
|
+
return element
|
|
717
|
+
}
|
|
718
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
719
|
+
return __assign(__assign({}, element), { insert: cloneDeep(element.insert) })
|
|
720
|
+
})
|
|
721
|
+
}
|
|
722
|
+
function cloneDeep(yText) {
|
|
723
|
+
var clone = new Y.XmlText()
|
|
724
|
+
var attributes = yText.getAttributes()
|
|
725
|
+
Object.entries(attributes).forEach(function (_a) {
|
|
726
|
+
var _b = __read(_a, 2),
|
|
727
|
+
key = _b[0],
|
|
728
|
+
value = _b[1]
|
|
729
|
+
clone.setAttribute(key, value)
|
|
730
|
+
})
|
|
731
|
+
clone.applyDelta(cloneInsertDeltaDeep(yTextToInsertDelta(yText)), {
|
|
732
|
+
sanitize: false,
|
|
733
|
+
})
|
|
734
|
+
return clone
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
738
|
+
function assertDocumentAttachment(sharedType) {
|
|
739
|
+
if (!sharedType.doc) {
|
|
740
|
+
throw new Error("shared type isn't attached to a document")
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
var STORED_POSITION_PREFIX = '__slateYjsStoredPosition_'
|
|
745
|
+
function slatePointToRelativePosition(sharedRoot, slateRoot, point) {
|
|
746
|
+
var _a = getYTarget(sharedRoot, slateRoot, point.path),
|
|
747
|
+
yTarget = _a.yTarget,
|
|
748
|
+
yParent = _a.yParent,
|
|
749
|
+
textRange = _a.textRange
|
|
750
|
+
if (yTarget) {
|
|
751
|
+
throw new Error('Slate point points to a non-text element inside sharedRoot')
|
|
752
|
+
}
|
|
753
|
+
var index = textRange.start + point.offset
|
|
754
|
+
return Y.createRelativePositionFromTypeIndex(yParent, index, index === textRange.end ? -1 : 0)
|
|
755
|
+
}
|
|
756
|
+
function absolutePositionToSlatePoint(sharedRoot, slateRoot, _a) {
|
|
757
|
+
var type = _a.type,
|
|
758
|
+
index = _a.index,
|
|
759
|
+
assoc = _a.assoc
|
|
760
|
+
if (!(type instanceof Y.XmlText)) {
|
|
761
|
+
throw new Error('Absolute position points to a non-XMLText')
|
|
762
|
+
}
|
|
763
|
+
var parentPath = getSlatePath(sharedRoot, slateRoot, type)
|
|
764
|
+
var parent = Node.get(slateRoot, parentPath)
|
|
765
|
+
if (Text.isText(parent)) {
|
|
766
|
+
throw new Error("Absolute position doesn't match slateRoot, cannot descent into text")
|
|
767
|
+
}
|
|
768
|
+
var _b = __read(
|
|
769
|
+
yOffsetToSlateOffsets(parent, index, {
|
|
770
|
+
assoc: assoc,
|
|
771
|
+
}),
|
|
772
|
+
2
|
|
773
|
+
),
|
|
774
|
+
pathOffset = _b[0],
|
|
775
|
+
textOffset = _b[1]
|
|
776
|
+
var target = parent.children[pathOffset]
|
|
777
|
+
if (!Text.isText(target)) {
|
|
778
|
+
return null
|
|
779
|
+
}
|
|
780
|
+
return {
|
|
781
|
+
path: __spreadArray(__spreadArray([], __read(parentPath)), [pathOffset]),
|
|
782
|
+
offset: textOffset,
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
function relativePositionToSlatePoint(sharedRoot, slateRoot, pos) {
|
|
786
|
+
if (!sharedRoot.doc) {
|
|
787
|
+
throw new Error("sharedRoot isn't attach to a yDoc")
|
|
788
|
+
}
|
|
789
|
+
var absPos = Y.createAbsolutePositionFromRelativePosition(pos, sharedRoot.doc)
|
|
790
|
+
return absPos && absolutePositionToSlatePoint(sharedRoot, slateRoot, absPos)
|
|
791
|
+
}
|
|
792
|
+
function getStoredPosition(sharedRoot, key) {
|
|
793
|
+
var rawPosition = sharedRoot.getAttribute(STORED_POSITION_PREFIX + key)
|
|
794
|
+
if (!rawPosition) {
|
|
795
|
+
return null
|
|
796
|
+
}
|
|
797
|
+
return Y.decodeRelativePosition(rawPosition)
|
|
798
|
+
}
|
|
799
|
+
function getStoredPositions(sharedRoot) {
|
|
800
|
+
return Object.fromEntries(
|
|
801
|
+
Object.entries(sharedRoot.getAttributes())
|
|
802
|
+
.filter(function (_a) {
|
|
803
|
+
var _b = __read(_a, 1),
|
|
804
|
+
key = _b[0]
|
|
805
|
+
return key.startsWith(STORED_POSITION_PREFIX)
|
|
806
|
+
})
|
|
807
|
+
.map(function (_a) {
|
|
808
|
+
var _b = __read(_a, 2),
|
|
809
|
+
key = _b[0],
|
|
810
|
+
position = _b[1]
|
|
811
|
+
return [
|
|
812
|
+
key.slice(STORED_POSITION_PREFIX.length),
|
|
813
|
+
Y.createRelativePositionFromJSON(position),
|
|
814
|
+
]
|
|
815
|
+
})
|
|
816
|
+
)
|
|
817
|
+
}
|
|
818
|
+
function getStoredPositionsAbsolute(sharedRoot) {
|
|
819
|
+
assertDocumentAttachment(sharedRoot)
|
|
820
|
+
return Object.fromEntries(
|
|
821
|
+
Object.entries(sharedRoot.getAttributes())
|
|
822
|
+
.filter(function (_a) {
|
|
823
|
+
var _b = __read(_a, 1),
|
|
824
|
+
key = _b[0]
|
|
825
|
+
return key.startsWith(STORED_POSITION_PREFIX)
|
|
826
|
+
})
|
|
827
|
+
.map(function (_a) {
|
|
828
|
+
var _b = __read(_a, 2),
|
|
829
|
+
key = _b[0],
|
|
830
|
+
position = _b[1]
|
|
831
|
+
return [
|
|
832
|
+
key.slice(STORED_POSITION_PREFIX.length),
|
|
833
|
+
Y.createAbsolutePositionFromRelativePosition(
|
|
834
|
+
Y.decodeRelativePosition(position),
|
|
835
|
+
sharedRoot.doc
|
|
836
|
+
),
|
|
837
|
+
]
|
|
838
|
+
})
|
|
839
|
+
.filter(function (_a) {
|
|
840
|
+
var _b = __read(_a, 2),
|
|
841
|
+
position = _b[1]
|
|
842
|
+
return position
|
|
843
|
+
})
|
|
844
|
+
)
|
|
845
|
+
}
|
|
846
|
+
function removeStoredPosition(sharedRoot, key) {
|
|
847
|
+
sharedRoot.removeAttribute(STORED_POSITION_PREFIX + key)
|
|
848
|
+
}
|
|
849
|
+
function setStoredPosition(sharedRoot, key, position) {
|
|
850
|
+
sharedRoot.setAttribute(STORED_POSITION_PREFIX + key, Y.encodeRelativePosition(position))
|
|
851
|
+
}
|
|
852
|
+
function getAbsolutePositionsInTextRange(absolutePositions, yTarget, textRange) {
|
|
853
|
+
return Object.fromEntries(
|
|
854
|
+
Object.entries(absolutePositions).filter(function (_a) {
|
|
855
|
+
var _b = __read(_a, 2),
|
|
856
|
+
position = _b[1]
|
|
857
|
+
if (position.type !== yTarget) {
|
|
858
|
+
return false
|
|
859
|
+
}
|
|
860
|
+
if (!textRange) {
|
|
861
|
+
return true
|
|
862
|
+
}
|
|
863
|
+
return position.assoc >= 0
|
|
864
|
+
? position.index >= textRange.start && position.index < textRange.end
|
|
865
|
+
: position.index > textRange.start && position.index >= textRange.end
|
|
866
|
+
})
|
|
867
|
+
)
|
|
868
|
+
}
|
|
869
|
+
function getAbsolutePositionsInYText(absolutePositions, yText, parentPath) {
|
|
870
|
+
var _a
|
|
871
|
+
if (parentPath === void 0) {
|
|
872
|
+
parentPath = ''
|
|
873
|
+
}
|
|
874
|
+
var positions =
|
|
875
|
+
((_a = {}), (_a[parentPath] = getAbsolutePositionsInTextRange(absolutePositions, yText)), _a)
|
|
876
|
+
var insertDelta = yTextToInsertDelta(yText)
|
|
877
|
+
insertDelta.forEach(function (_a, i) {
|
|
878
|
+
var insert = _a.insert
|
|
879
|
+
if (insert instanceof Y.XmlText) {
|
|
880
|
+
Object.assign(
|
|
881
|
+
positions,
|
|
882
|
+
getAbsolutePositionsInYText(
|
|
883
|
+
absolutePositions,
|
|
884
|
+
insert,
|
|
885
|
+
parentPath ? parentPath + '.' + i : i.toString()
|
|
886
|
+
)
|
|
887
|
+
)
|
|
888
|
+
}
|
|
889
|
+
})
|
|
890
|
+
return positions
|
|
891
|
+
}
|
|
892
|
+
function getStoredPositionsInDeltaAbsolute(sharedRoot, yText, delta, deltaOffset) {
|
|
893
|
+
if (deltaOffset === void 0) {
|
|
894
|
+
deltaOffset = 0
|
|
895
|
+
}
|
|
896
|
+
var absolutePositions = getStoredPositionsAbsolute(sharedRoot)
|
|
897
|
+
var positions = {
|
|
898
|
+
'': getAbsolutePositionsInTextRange(absolutePositions, yText, {
|
|
899
|
+
start: deltaOffset,
|
|
900
|
+
end: deltaOffset + getInsertDeltaLength(delta),
|
|
901
|
+
}),
|
|
902
|
+
}
|
|
903
|
+
delta.forEach(function (_a, i) {
|
|
904
|
+
var insert = _a.insert
|
|
905
|
+
if (insert instanceof Y.XmlText) {
|
|
906
|
+
Object.assign(positions, getAbsolutePositionsInYText(absolutePositions, insert, i.toString()))
|
|
907
|
+
}
|
|
908
|
+
})
|
|
909
|
+
return positions
|
|
910
|
+
}
|
|
911
|
+
function restoreStoredPositionsWithDeltaAbsolute(
|
|
912
|
+
sharedRoot,
|
|
913
|
+
yText,
|
|
914
|
+
absolutePositions,
|
|
915
|
+
delta,
|
|
916
|
+
newDeltaOffset,
|
|
917
|
+
previousDeltaOffset,
|
|
918
|
+
path
|
|
919
|
+
) {
|
|
920
|
+
if (newDeltaOffset === void 0) {
|
|
921
|
+
newDeltaOffset = 0
|
|
922
|
+
}
|
|
923
|
+
if (previousDeltaOffset === void 0) {
|
|
924
|
+
previousDeltaOffset = 0
|
|
925
|
+
}
|
|
926
|
+
if (path === void 0) {
|
|
927
|
+
path = ''
|
|
928
|
+
}
|
|
929
|
+
var toRestore = absolutePositions[path]
|
|
930
|
+
if (toRestore) {
|
|
931
|
+
Object.entries(toRestore).forEach(function (_a) {
|
|
932
|
+
var _b = __read(_a, 2),
|
|
933
|
+
key = _b[0],
|
|
934
|
+
position = _b[1]
|
|
935
|
+
setStoredPosition(
|
|
936
|
+
sharedRoot,
|
|
937
|
+
key,
|
|
938
|
+
Y.createRelativePositionFromTypeIndex(
|
|
939
|
+
yText,
|
|
940
|
+
position.index - previousDeltaOffset + newDeltaOffset,
|
|
941
|
+
position.assoc
|
|
942
|
+
)
|
|
943
|
+
)
|
|
944
|
+
})
|
|
945
|
+
}
|
|
946
|
+
delta.forEach(function (_a, i) {
|
|
947
|
+
var insert = _a.insert
|
|
948
|
+
if (insert instanceof Y.XmlText) {
|
|
949
|
+
restoreStoredPositionsWithDeltaAbsolute(
|
|
950
|
+
sharedRoot,
|
|
951
|
+
insert,
|
|
952
|
+
absolutePositions,
|
|
953
|
+
yTextToInsertDelta(insert),
|
|
954
|
+
0,
|
|
955
|
+
0,
|
|
956
|
+
path ? path + '.' + i : i.toString()
|
|
957
|
+
)
|
|
958
|
+
}
|
|
959
|
+
})
|
|
960
|
+
}
|
|
961
|
+
function slateRangeToRelativeRange(sharedRoot, slateRoot, range) {
|
|
962
|
+
return {
|
|
963
|
+
anchor: slatePointToRelativePosition(sharedRoot, slateRoot, range.anchor),
|
|
964
|
+
focus: slatePointToRelativePosition(sharedRoot, slateRoot, range.focus),
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
function relativeRangeToSlateRange(sharedRoot, slateRoot, range) {
|
|
968
|
+
var anchor = relativePositionToSlatePoint(sharedRoot, slateRoot, range.anchor)
|
|
969
|
+
if (!anchor) {
|
|
970
|
+
return null
|
|
971
|
+
}
|
|
972
|
+
var focus = relativePositionToSlatePoint(sharedRoot, slateRoot, range.focus)
|
|
973
|
+
if (!focus) {
|
|
974
|
+
return null
|
|
975
|
+
}
|
|
976
|
+
return { anchor: anchor, focus: focus }
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
function mergeNode(sharedRoot, slateRoot, op) {
|
|
980
|
+
var target = getYTarget(sharedRoot, slateRoot, op.path)
|
|
981
|
+
var prev = getYTarget(target.yParent, target.slateParent, Path.previous(op.path.slice(-1)))
|
|
982
|
+
if (!target.yTarget !== !prev.yTarget) {
|
|
983
|
+
throw new Error('Cannot merge y text with y element')
|
|
984
|
+
}
|
|
985
|
+
if (!prev.yTarget || !target.yTarget) {
|
|
986
|
+
var parent_1 = target.yParent,
|
|
987
|
+
textRange = target.textRange,
|
|
988
|
+
slateTarget = target.slateTarget
|
|
989
|
+
if (!slateTarget) {
|
|
990
|
+
throw new Error('Expected Slate target node for merge op.')
|
|
991
|
+
}
|
|
992
|
+
var prevSibling = Node.get(slateRoot, Path.previous(op.path))
|
|
993
|
+
if (!Text.isText(prevSibling)) {
|
|
994
|
+
throw new Error('Path points to Y.Text but not a Slate text node.')
|
|
995
|
+
}
|
|
996
|
+
var targetProps = getProperties(slateTarget)
|
|
997
|
+
var prevSiblingProps_1 = getProperties(prevSibling)
|
|
998
|
+
var unsetProps = Object.keys(targetProps).reduce(function (acc, key) {
|
|
999
|
+
var _a
|
|
1000
|
+
var prevSiblingHasProp = key in prevSiblingProps_1
|
|
1001
|
+
return prevSiblingHasProp
|
|
1002
|
+
? acc
|
|
1003
|
+
: __assign(__assign({}, acc), ((_a = {}), (_a[key] = null), _a))
|
|
1004
|
+
}, {})
|
|
1005
|
+
return parent_1.format(
|
|
1006
|
+
textRange.start,
|
|
1007
|
+
textRange.end - textRange.start,
|
|
1008
|
+
__assign(__assign({}, unsetProps), prevSiblingProps_1)
|
|
1009
|
+
)
|
|
1010
|
+
}
|
|
1011
|
+
var deltaApplyYOffset = prev.yTarget.length
|
|
1012
|
+
var targetDelta = yTextToInsertDelta(target.yTarget)
|
|
1013
|
+
var clonedDelta = cloneInsertDeltaDeep(targetDelta)
|
|
1014
|
+
var storedPositions = getStoredPositionsInDeltaAbsolute(
|
|
1015
|
+
sharedRoot,
|
|
1016
|
+
target.yTarget,
|
|
1017
|
+
targetDelta,
|
|
1018
|
+
deltaApplyYOffset
|
|
1019
|
+
)
|
|
1020
|
+
var applyDelta = __spreadArray([{ retain: deltaApplyYOffset }], __read(clonedDelta))
|
|
1021
|
+
prev.yTarget.applyDelta(applyDelta, {
|
|
1022
|
+
sanitize: false,
|
|
1023
|
+
})
|
|
1024
|
+
target.yParent.delete(target.textRange.start, target.textRange.end - target.textRange.start)
|
|
1025
|
+
restoreStoredPositionsWithDeltaAbsolute(
|
|
1026
|
+
sharedRoot,
|
|
1027
|
+
prev.yTarget,
|
|
1028
|
+
storedPositions,
|
|
1029
|
+
clonedDelta,
|
|
1030
|
+
deltaApplyYOffset
|
|
1031
|
+
)
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
function moveNode(sharedRoot, slateRoot, op) {
|
|
1035
|
+
var newParentPath = Path.parent(op.newPath)
|
|
1036
|
+
var newPathOffset = op.newPath[op.newPath.length - 1]
|
|
1037
|
+
var parent = Node.get(slateRoot, newParentPath)
|
|
1038
|
+
if (Text.isText(parent)) {
|
|
1039
|
+
throw new Error('Cannot move slate node into text element')
|
|
1040
|
+
}
|
|
1041
|
+
var normalizedNewPath = __spreadArray(__spreadArray([], __read(newParentPath)), [
|
|
1042
|
+
Math.min(newPathOffset, parent.children.length),
|
|
1043
|
+
])
|
|
1044
|
+
var origin = getYTarget(sharedRoot, slateRoot, op.path)
|
|
1045
|
+
var target = getYTarget(sharedRoot, slateRoot, normalizedNewPath)
|
|
1046
|
+
var insertDelta = cloneInsertDeltaDeep(origin.targetDelta)
|
|
1047
|
+
var storedPositions = getStoredPositionsInDeltaAbsolute(
|
|
1048
|
+
sharedRoot,
|
|
1049
|
+
origin.yParent,
|
|
1050
|
+
origin.targetDelta
|
|
1051
|
+
)
|
|
1052
|
+
origin.yParent.delete(origin.textRange.start, origin.textRange.end - origin.textRange.start)
|
|
1053
|
+
var targetLength = getInsertDeltaLength(yTextToInsertDelta(target.yParent))
|
|
1054
|
+
var deltaApplyYOffset = Math.min(target.textRange.start, targetLength)
|
|
1055
|
+
var applyDelta = __spreadArray([{ retain: deltaApplyYOffset }], __read(insertDelta))
|
|
1056
|
+
target.yParent.applyDelta(applyDelta, { sanitize: false })
|
|
1057
|
+
restoreStoredPositionsWithDeltaAbsolute(
|
|
1058
|
+
sharedRoot,
|
|
1059
|
+
target.yParent,
|
|
1060
|
+
storedPositions,
|
|
1061
|
+
insertDelta,
|
|
1062
|
+
deltaApplyYOffset,
|
|
1063
|
+
origin.textRange.start
|
|
1064
|
+
)
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
function removeNode(sharedRoot, slateRoot, op) {
|
|
1068
|
+
var _a = getYTarget(sharedRoot, slateRoot, op.path),
|
|
1069
|
+
parent = _a.yParent,
|
|
1070
|
+
textRange = _a.textRange
|
|
1071
|
+
parent.delete(textRange.start, textRange.end - textRange.start)
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
function setNode(sharedRoot, slateRoot, op) {
|
|
1075
|
+
var _a = getYTarget(sharedRoot, slateRoot, op.path),
|
|
1076
|
+
yTarget = _a.yTarget,
|
|
1077
|
+
textRange = _a.textRange,
|
|
1078
|
+
yParent = _a.yParent
|
|
1079
|
+
if (yTarget) {
|
|
1080
|
+
Object.entries(op.newProperties).forEach(function (_a) {
|
|
1081
|
+
var _b = __read(_a, 2),
|
|
1082
|
+
key = _b[0],
|
|
1083
|
+
value = _b[1]
|
|
1084
|
+
if (value === null) {
|
|
1085
|
+
return yTarget.removeAttribute(key)
|
|
1086
|
+
}
|
|
1087
|
+
yTarget.setAttribute(key, value)
|
|
1088
|
+
})
|
|
1089
|
+
return Object.entries(op.properties).forEach(function (_a) {
|
|
1090
|
+
var _b = __read(_a, 1),
|
|
1091
|
+
key = _b[0]
|
|
1092
|
+
if (!Object.prototype.hasOwnProperty.call(op.newProperties, key)) {
|
|
1093
|
+
yTarget.removeAttribute(key)
|
|
1094
|
+
}
|
|
1095
|
+
})
|
|
1096
|
+
}
|
|
1097
|
+
var unset = Object.fromEntries(
|
|
1098
|
+
Object.keys(op.properties).map(function (key) {
|
|
1099
|
+
return [key, null]
|
|
1100
|
+
})
|
|
1101
|
+
)
|
|
1102
|
+
var newProperties = __assign(__assign({}, unset), op.newProperties)
|
|
1103
|
+
yParent.format(textRange.start, textRange.end - textRange.start, newProperties)
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
function splitNode(sharedRoot, slateRoot, op) {
|
|
1107
|
+
var target = getYTarget(sharedRoot, slateRoot, op.path)
|
|
1108
|
+
if (!target.slateTarget) {
|
|
1109
|
+
throw new Error('Y target without corresponding slate node')
|
|
1110
|
+
}
|
|
1111
|
+
if (!target.yTarget) {
|
|
1112
|
+
if (!Text.isText(target.slateTarget)) {
|
|
1113
|
+
throw new Error('Mismatch node type between y target and slate node')
|
|
1114
|
+
}
|
|
1115
|
+
var unset_1 = {}
|
|
1116
|
+
target.targetDelta.forEach(function (element) {
|
|
1117
|
+
if (element.attributes) {
|
|
1118
|
+
Object.keys(element.attributes).forEach(function (key) {
|
|
1119
|
+
unset_1[key] = null
|
|
1120
|
+
})
|
|
1121
|
+
}
|
|
1122
|
+
})
|
|
1123
|
+
return target.yParent.format(
|
|
1124
|
+
target.textRange.start,
|
|
1125
|
+
target.textRange.end - target.textRange.start,
|
|
1126
|
+
__assign(__assign({}, unset_1), op.properties)
|
|
1127
|
+
)
|
|
1128
|
+
}
|
|
1129
|
+
if (Text.isText(target.slateTarget)) {
|
|
1130
|
+
throw new Error('Mismatch node type between y target and slate node')
|
|
1131
|
+
}
|
|
1132
|
+
var splitTarget = getYTarget(target.yTarget, target.slateTarget, [op.position])
|
|
1133
|
+
var ySplitOffset = target.slateTarget.children
|
|
1134
|
+
.slice(0, op.position)
|
|
1135
|
+
.reduce(function (length, child) {
|
|
1136
|
+
return length + getSlateNodeYLength(child)
|
|
1137
|
+
}, 0)
|
|
1138
|
+
var length = target.slateTarget.children.reduce(function (current, child) {
|
|
1139
|
+
return current + getSlateNodeYLength(child)
|
|
1140
|
+
}, 0)
|
|
1141
|
+
var splitDelta = sliceInsertDelta(
|
|
1142
|
+
yTextToInsertDelta(target.yTarget),
|
|
1143
|
+
ySplitOffset,
|
|
1144
|
+
length - ySplitOffset
|
|
1145
|
+
)
|
|
1146
|
+
var clonedDelta = cloneInsertDeltaDeep(splitDelta)
|
|
1147
|
+
var storedPositions = getStoredPositionsInDeltaAbsolute(
|
|
1148
|
+
sharedRoot,
|
|
1149
|
+
target.yTarget,
|
|
1150
|
+
splitDelta,
|
|
1151
|
+
ySplitOffset
|
|
1152
|
+
)
|
|
1153
|
+
var toInsert = new Y.XmlText()
|
|
1154
|
+
toInsert.applyDelta(clonedDelta, {
|
|
1155
|
+
sanitize: false,
|
|
1156
|
+
})
|
|
1157
|
+
Object.entries(op.properties).forEach(function (_a) {
|
|
1158
|
+
var _b = __read(_a, 2),
|
|
1159
|
+
key = _b[0],
|
|
1160
|
+
value = _b[1]
|
|
1161
|
+
toInsert.setAttribute(key, value)
|
|
1162
|
+
})
|
|
1163
|
+
target.yTarget.delete(
|
|
1164
|
+
splitTarget.textRange.start,
|
|
1165
|
+
target.yTarget.length - splitTarget.textRange.start
|
|
1166
|
+
)
|
|
1167
|
+
target.yParent.insertEmbed(target.textRange.end, toInsert)
|
|
1168
|
+
restoreStoredPositionsWithDeltaAbsolute(
|
|
1169
|
+
sharedRoot,
|
|
1170
|
+
toInsert,
|
|
1171
|
+
storedPositions,
|
|
1172
|
+
clonedDelta,
|
|
1173
|
+
0,
|
|
1174
|
+
ySplitOffset
|
|
1175
|
+
)
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
var NODE_MAPPER = {
|
|
1179
|
+
insert_node: insertNode,
|
|
1180
|
+
remove_node: removeNode,
|
|
1181
|
+
set_node: setNode,
|
|
1182
|
+
merge_node: mergeNode,
|
|
1183
|
+
move_node: moveNode,
|
|
1184
|
+
split_node: splitNode,
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
function insertText(sharedRoot, slateRoot, op) {
|
|
1188
|
+
var _a = getYTarget(sharedRoot, slateRoot, op.path),
|
|
1189
|
+
target = _a.yParent,
|
|
1190
|
+
textRange = _a.textRange
|
|
1191
|
+
var targetNode = Node.get(slateRoot, op.path)
|
|
1192
|
+
if (!Text.isText(targetNode)) {
|
|
1193
|
+
throw new Error('Cannot insert text into non-text node')
|
|
1194
|
+
}
|
|
1195
|
+
target.insert(textRange.start + op.offset, op.text, getProperties(targetNode))
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
function removeText(sharedRoot, slateRoot, op) {
|
|
1199
|
+
var _a = getYTarget(sharedRoot, slateRoot, op.path),
|
|
1200
|
+
target = _a.yParent,
|
|
1201
|
+
textRange = _a.textRange
|
|
1202
|
+
target.delete(textRange.start + op.offset, op.text.length)
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
var TEXT_MAPPER = {
|
|
1206
|
+
insert_text: insertText,
|
|
1207
|
+
remove_text: removeText,
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
1211
|
+
var NOOP = function () {}
|
|
1212
|
+
var opMappers = __assign(__assign(__assign({}, TEXT_MAPPER), NODE_MAPPER), { set_selection: NOOP })
|
|
1213
|
+
function applySlateOp(sharedRoot, slateRoot, op) {
|
|
1214
|
+
var apply = opMappers[op.type]
|
|
1215
|
+
if (!apply) {
|
|
1216
|
+
throw new Error('Unknown operation: ' + op.type)
|
|
1217
|
+
}
|
|
1218
|
+
apply(sharedRoot, slateRoot, op)
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
var DEFAULT_LOCAL_ORIGIN = Symbol('slate-yjs-operation')
|
|
1222
|
+
var DEFAULT_POSITION_STORAGE_ORIGIN = Symbol('slate-yjs-position-storage')
|
|
1223
|
+
var ORIGIN = new WeakMap()
|
|
1224
|
+
var LOCAL_CHANGES = new WeakMap()
|
|
1225
|
+
var CONNECTED = new WeakSet()
|
|
1226
|
+
var YjsEditor = {
|
|
1227
|
+
isYjsEditor: function (value) {
|
|
1228
|
+
return (
|
|
1229
|
+
Editor.isEditor(value) &&
|
|
1230
|
+
value.sharedRoot instanceof Y.XmlText &&
|
|
1231
|
+
'localOrigin' in value &&
|
|
1232
|
+
'positionStorageOrigin' in value &&
|
|
1233
|
+
typeof value.applyRemoteEvents === 'function' &&
|
|
1234
|
+
typeof value.storeLocalChange === 'function' &&
|
|
1235
|
+
typeof value.flushLocalChanges === 'function' &&
|
|
1236
|
+
typeof value.isLocalOrigin === 'function' &&
|
|
1237
|
+
typeof value.connect === 'function' &&
|
|
1238
|
+
typeof value.disconnect === 'function'
|
|
1239
|
+
)
|
|
1240
|
+
},
|
|
1241
|
+
localChanges: function (editor) {
|
|
1242
|
+
var _a
|
|
1243
|
+
return (_a = LOCAL_CHANGES.get(editor)) !== null && _a !== void 0 ? _a : []
|
|
1244
|
+
},
|
|
1245
|
+
applyRemoteEvents: function (editor, events, origin) {
|
|
1246
|
+
editor.applyRemoteEvents(events, origin)
|
|
1247
|
+
},
|
|
1248
|
+
storeLocalChange: function (editor, op) {
|
|
1249
|
+
editor.storeLocalChange(op)
|
|
1250
|
+
},
|
|
1251
|
+
flushLocalChanges: function (editor) {
|
|
1252
|
+
editor.flushLocalChanges()
|
|
1253
|
+
},
|
|
1254
|
+
connected: function (editor) {
|
|
1255
|
+
return CONNECTED.has(editor)
|
|
1256
|
+
},
|
|
1257
|
+
connect: function (editor) {
|
|
1258
|
+
editor.connect()
|
|
1259
|
+
},
|
|
1260
|
+
disconnect: function (editor) {
|
|
1261
|
+
editor.disconnect()
|
|
1262
|
+
},
|
|
1263
|
+
isLocal: function (editor) {
|
|
1264
|
+
return editor.isLocalOrigin(YjsEditor.origin(editor))
|
|
1265
|
+
},
|
|
1266
|
+
origin: function (editor) {
|
|
1267
|
+
var origin = ORIGIN.get(editor)
|
|
1268
|
+
return origin !== undefined ? origin : editor.localOrigin
|
|
1269
|
+
},
|
|
1270
|
+
withOrigin: function (editor, origin, fn) {
|
|
1271
|
+
var prev = YjsEditor.origin(editor)
|
|
1272
|
+
ORIGIN.set(editor, origin)
|
|
1273
|
+
fn()
|
|
1274
|
+
ORIGIN.set(editor, prev)
|
|
1275
|
+
},
|
|
1276
|
+
storePosition: function (editor, key, point) {
|
|
1277
|
+
var sharedRoot = editor.sharedRoot,
|
|
1278
|
+
locationStorageOrigin = editor.positionStorageOrigin
|
|
1279
|
+
assertDocumentAttachment(sharedRoot)
|
|
1280
|
+
var position = slatePointToRelativePosition(sharedRoot, editor, point)
|
|
1281
|
+
sharedRoot.doc.transact(function () {
|
|
1282
|
+
setStoredPosition(sharedRoot, key, position)
|
|
1283
|
+
}, locationStorageOrigin)
|
|
1284
|
+
},
|
|
1285
|
+
removeStoredPosition: function (editor, key) {
|
|
1286
|
+
var sharedRoot = editor.sharedRoot,
|
|
1287
|
+
locationStorageOrigin = editor.positionStorageOrigin
|
|
1288
|
+
assertDocumentAttachment(sharedRoot)
|
|
1289
|
+
sharedRoot.doc.transact(function () {
|
|
1290
|
+
removeStoredPosition(sharedRoot, key)
|
|
1291
|
+
}, locationStorageOrigin)
|
|
1292
|
+
},
|
|
1293
|
+
position: function (editor, key) {
|
|
1294
|
+
var position = getStoredPosition(editor.sharedRoot, key)
|
|
1295
|
+
if (!position) {
|
|
1296
|
+
return undefined
|
|
1297
|
+
}
|
|
1298
|
+
return relativePositionToSlatePoint(editor.sharedRoot, editor, position)
|
|
1299
|
+
},
|
|
1300
|
+
storedPositionsRelative: function (editor) {
|
|
1301
|
+
return getStoredPositions(editor.sharedRoot)
|
|
1302
|
+
},
|
|
1303
|
+
}
|
|
1304
|
+
function withYjs(sharedRoot, options) {
|
|
1305
|
+
if (options === void 0) {
|
|
1306
|
+
options = {}
|
|
1307
|
+
}
|
|
1308
|
+
return function (editor) {
|
|
1309
|
+
var _a, _b
|
|
1310
|
+
var e = editor
|
|
1311
|
+
e.sharedRoot = sharedRoot
|
|
1312
|
+
e.localOrigin = (_a = options.localOrigin) !== null && _a !== void 0 ? _a : DEFAULT_LOCAL_ORIGIN
|
|
1313
|
+
e.positionStorageOrigin =
|
|
1314
|
+
(_b = options.positionStorageOrigin) !== null && _b !== void 0
|
|
1315
|
+
? _b
|
|
1316
|
+
: DEFAULT_POSITION_STORAGE_ORIGIN
|
|
1317
|
+
e.applyRemoteEvents = function (events, origin) {
|
|
1318
|
+
YjsEditor.flushLocalChanges(e)
|
|
1319
|
+
Editor.withoutNormalizing(e, function () {
|
|
1320
|
+
YjsEditor.withOrigin(e, origin, function () {
|
|
1321
|
+
applyYjsEvents(e.sharedRoot, e, events)
|
|
1322
|
+
})
|
|
1323
|
+
})
|
|
1324
|
+
}
|
|
1325
|
+
e.isLocalOrigin = function (origin) {
|
|
1326
|
+
return origin === e.localOrigin
|
|
1327
|
+
}
|
|
1328
|
+
var handleYEvents = function (events, transaction) {
|
|
1329
|
+
if (e.isLocalOrigin(transaction.origin)) {
|
|
1330
|
+
return
|
|
1331
|
+
}
|
|
1332
|
+
YjsEditor.applyRemoteEvents(e, events, transaction.origin)
|
|
1333
|
+
}
|
|
1334
|
+
var autoConnectTimeoutId = null
|
|
1335
|
+
if (options.autoConnect) {
|
|
1336
|
+
autoConnectTimeoutId = setTimeout(function () {
|
|
1337
|
+
autoConnectTimeoutId = null
|
|
1338
|
+
YjsEditor.connect(e)
|
|
1339
|
+
})
|
|
1340
|
+
}
|
|
1341
|
+
e.connect = function () {
|
|
1342
|
+
if (YjsEditor.connected(e)) {
|
|
1343
|
+
throw new Error('already connected')
|
|
1344
|
+
}
|
|
1345
|
+
e.sharedRoot.observeDeep(handleYEvents)
|
|
1346
|
+
var content = yTextToSlateElement(e.sharedRoot)
|
|
1347
|
+
e.children = content.children
|
|
1348
|
+
CONNECTED.add(e)
|
|
1349
|
+
Editor.normalize(editor, { force: true })
|
|
1350
|
+
if (!editor.operations.length) {
|
|
1351
|
+
editor.onChange()
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
e.disconnect = function () {
|
|
1355
|
+
if (autoConnectTimeoutId) {
|
|
1356
|
+
clearTimeout(autoConnectTimeoutId)
|
|
1357
|
+
}
|
|
1358
|
+
YjsEditor.flushLocalChanges(e)
|
|
1359
|
+
e.sharedRoot.unobserveDeep(handleYEvents)
|
|
1360
|
+
CONNECTED.delete(e)
|
|
1361
|
+
}
|
|
1362
|
+
e.storeLocalChange = function (op) {
|
|
1363
|
+
LOCAL_CHANGES.set(
|
|
1364
|
+
e,
|
|
1365
|
+
__spreadArray(__spreadArray([], __read(YjsEditor.localChanges(e))), [
|
|
1366
|
+
{ op: op, doc: editor.children, origin: YjsEditor.origin(e) },
|
|
1367
|
+
])
|
|
1368
|
+
)
|
|
1369
|
+
}
|
|
1370
|
+
e.flushLocalChanges = function () {
|
|
1371
|
+
assertDocumentAttachment(e.sharedRoot)
|
|
1372
|
+
var localChanges = YjsEditor.localChanges(e)
|
|
1373
|
+
LOCAL_CHANGES.delete(e)
|
|
1374
|
+
var txGroups = []
|
|
1375
|
+
localChanges.forEach(function (change) {
|
|
1376
|
+
var currentGroup = txGroups[txGroups.length - 1]
|
|
1377
|
+
if (currentGroup && currentGroup[0].origin === change.origin) {
|
|
1378
|
+
return currentGroup.push(change)
|
|
1379
|
+
}
|
|
1380
|
+
txGroups.push([change])
|
|
1381
|
+
})
|
|
1382
|
+
txGroups.forEach(function (txGroup) {
|
|
1383
|
+
assertDocumentAttachment(e.sharedRoot)
|
|
1384
|
+
e.sharedRoot.doc.transact(function () {
|
|
1385
|
+
txGroup.forEach(function (change) {
|
|
1386
|
+
assertDocumentAttachment(e.sharedRoot)
|
|
1387
|
+
applySlateOp(e.sharedRoot, { children: change.doc }, change.op)
|
|
1388
|
+
})
|
|
1389
|
+
}, txGroup[0].origin)
|
|
1390
|
+
})
|
|
1391
|
+
}
|
|
1392
|
+
var apply = e.apply,
|
|
1393
|
+
onChange = e.onChange
|
|
1394
|
+
e.apply = function (op) {
|
|
1395
|
+
if (YjsEditor.connected(e) && YjsEditor.isLocal(e)) {
|
|
1396
|
+
YjsEditor.storeLocalChange(e, op)
|
|
1397
|
+
}
|
|
1398
|
+
apply(op)
|
|
1399
|
+
}
|
|
1400
|
+
e.onChange = function () {
|
|
1401
|
+
if (YjsEditor.connected(e)) {
|
|
1402
|
+
YjsEditor.flushLocalChanges(e)
|
|
1403
|
+
}
|
|
1404
|
+
onChange()
|
|
1405
|
+
}
|
|
1406
|
+
return e
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
var LAST_SELECTION = new WeakMap()
|
|
1411
|
+
var DEFAULT_WITHOUT_SAVING_ORIGIN = Symbol('slate-yjs-history-without-saving')
|
|
1412
|
+
var YHistoryEditor = {
|
|
1413
|
+
isYHistoryEditor: function (value) {
|
|
1414
|
+
return (
|
|
1415
|
+
YjsEditor.isYjsEditor(value) &&
|
|
1416
|
+
value.undoManager instanceof Y.UndoManager &&
|
|
1417
|
+
typeof value.undo === 'function' &&
|
|
1418
|
+
typeof value.redo === 'function' &&
|
|
1419
|
+
'withoutSavingOrigin' in value
|
|
1420
|
+
)
|
|
1421
|
+
},
|
|
1422
|
+
canUndo: function (editor) {
|
|
1423
|
+
return editor.undoManager.undoStack.length > 0
|
|
1424
|
+
},
|
|
1425
|
+
canRedo: function (editor) {
|
|
1426
|
+
return editor.undoManager.redoStack.length > 0
|
|
1427
|
+
},
|
|
1428
|
+
isSaving: function (editor) {
|
|
1429
|
+
return editor.undoManager.trackedOrigins.has(YjsEditor.origin(editor))
|
|
1430
|
+
},
|
|
1431
|
+
withoutSaving: function (editor, fn) {
|
|
1432
|
+
YjsEditor.withOrigin(editor, editor.withoutSavingOrigin, fn)
|
|
1433
|
+
},
|
|
1434
|
+
}
|
|
1435
|
+
function withYHistory(options) {
|
|
1436
|
+
if (options === void 0) {
|
|
1437
|
+
options = {}
|
|
1438
|
+
}
|
|
1439
|
+
return function (editor) {
|
|
1440
|
+
var e = editor
|
|
1441
|
+
// 将 trackedOrigins 的初始化放到 editor 被传入之后
|
|
1442
|
+
var _a = options.withoutSavingOrigin,
|
|
1443
|
+
withoutSavingOrigin = _a === void 0 ? DEFAULT_WITHOUT_SAVING_ORIGIN : _a,
|
|
1444
|
+
_b = options.trackedOrigins,
|
|
1445
|
+
trackedOrigins = _b === void 0 ? new Set([e.localOrigin]) : _b,
|
|
1446
|
+
restOptions = __rest(options, ['withoutSavingOrigin', 'trackedOrigins'])
|
|
1447
|
+
var undoManager = new Y.UndoManager(
|
|
1448
|
+
e.sharedRoot,
|
|
1449
|
+
__assign({ trackedOrigins: trackedOrigins }, restOptions)
|
|
1450
|
+
)
|
|
1451
|
+
e.undoManager = undoManager
|
|
1452
|
+
e.withoutSavingOrigin = withoutSavingOrigin
|
|
1453
|
+
var onChange = e.onChange,
|
|
1454
|
+
isLocalOrigin = e.isLocalOrigin
|
|
1455
|
+
e.onChange = function () {
|
|
1456
|
+
onChange()
|
|
1457
|
+
LAST_SELECTION.set(e, e.selection && slateRangeToRelativeRange(e.sharedRoot, e, e.selection))
|
|
1458
|
+
}
|
|
1459
|
+
e.isLocalOrigin = function (origin) {
|
|
1460
|
+
return origin === e.withoutSavingOrigin || isLocalOrigin(origin)
|
|
1461
|
+
}
|
|
1462
|
+
var handleStackItemAdded = function (_a) {
|
|
1463
|
+
var stackItem = _a.stackItem
|
|
1464
|
+
stackItem.meta.set(
|
|
1465
|
+
'selection',
|
|
1466
|
+
e.selection && slateRangeToRelativeRange(e.sharedRoot, e, e.selection)
|
|
1467
|
+
)
|
|
1468
|
+
stackItem.meta.set('selectionBefore', LAST_SELECTION.get(e))
|
|
1469
|
+
}
|
|
1470
|
+
var handleStackItemUpdated = function (_a) {
|
|
1471
|
+
var stackItem = _a.stackItem
|
|
1472
|
+
stackItem.meta.set(
|
|
1473
|
+
'selection',
|
|
1474
|
+
e.selection && slateRangeToRelativeRange(e.sharedRoot, e, e.selection)
|
|
1475
|
+
)
|
|
1476
|
+
}
|
|
1477
|
+
var handleStackItemPopped = function (_a) {
|
|
1478
|
+
var stackItem = _a.stackItem,
|
|
1479
|
+
type = _a.type
|
|
1480
|
+
// TODO: Change once https://github.com/yjs/yjs/issues/353 is resolved
|
|
1481
|
+
var inverseStack = type === 'undo' ? e.undoManager.redoStack : e.undoManager.undoStack
|
|
1482
|
+
var inverseItem = inverseStack[inverseStack.length - 1]
|
|
1483
|
+
if (inverseItem) {
|
|
1484
|
+
inverseItem.meta.set('selection', stackItem.meta.get('selectionBefore'))
|
|
1485
|
+
inverseItem.meta.set('selectionBefore', stackItem.meta.get('selection'))
|
|
1486
|
+
}
|
|
1487
|
+
var relativeSelection = stackItem.meta.get('selectionBefore')
|
|
1488
|
+
if (!relativeSelection) {
|
|
1489
|
+
return
|
|
1490
|
+
}
|
|
1491
|
+
var selection = relativeRangeToSlateRange(e.sharedRoot, e, relativeSelection)
|
|
1492
|
+
if (!selection) {
|
|
1493
|
+
return
|
|
1494
|
+
}
|
|
1495
|
+
Transforms.select(e, selection)
|
|
1496
|
+
}
|
|
1497
|
+
var connect = e.connect,
|
|
1498
|
+
disconnect = e.disconnect
|
|
1499
|
+
e.connect = function () {
|
|
1500
|
+
connect()
|
|
1501
|
+
e.undoManager.on('stack-item-added', handleStackItemAdded)
|
|
1502
|
+
e.undoManager.on('stack-item-popped', handleStackItemPopped)
|
|
1503
|
+
e.undoManager.on('stack-item-updated', handleStackItemUpdated)
|
|
1504
|
+
}
|
|
1505
|
+
e.disconnect = function () {
|
|
1506
|
+
e.undoManager.off('stack-item-added', handleStackItemAdded)
|
|
1507
|
+
e.undoManager.off('stack-item-popped', handleStackItemPopped)
|
|
1508
|
+
e.undoManager.off('stack-item-updated', handleStackItemUpdated)
|
|
1509
|
+
disconnect()
|
|
1510
|
+
}
|
|
1511
|
+
e.undo = function () {
|
|
1512
|
+
if (YjsEditor.connected(e)) {
|
|
1513
|
+
YjsEditor.flushLocalChanges(e)
|
|
1514
|
+
e.undoManager.undo()
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
e.redo = function () {
|
|
1518
|
+
if (YjsEditor.connected(e)) {
|
|
1519
|
+
YjsEditor.flushLocalChanges(e)
|
|
1520
|
+
e.undoManager.redo()
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
return e
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
var CURSOR_CHANGE_EVENT_LISTENERS = new WeakMap()
|
|
1528
|
+
var CursorEditor = {
|
|
1529
|
+
isCursorEditor: function (value) {
|
|
1530
|
+
return (
|
|
1531
|
+
YjsEditor.isYjsEditor(value) &&
|
|
1532
|
+
value.awareness &&
|
|
1533
|
+
typeof value.cursorDataField === 'string' &&
|
|
1534
|
+
typeof value.selectionStateField === 'string' &&
|
|
1535
|
+
typeof value.sendCursorPosition === 'function' &&
|
|
1536
|
+
typeof value.sendCursorData === 'function'
|
|
1537
|
+
)
|
|
1538
|
+
},
|
|
1539
|
+
sendCursorPosition: function (editor, range) {
|
|
1540
|
+
if (range === void 0) {
|
|
1541
|
+
range = editor.selection
|
|
1542
|
+
}
|
|
1543
|
+
editor.sendCursorPosition(range)
|
|
1544
|
+
},
|
|
1545
|
+
sendCursorData: function (editor, data) {
|
|
1546
|
+
editor.sendCursorData(data)
|
|
1547
|
+
},
|
|
1548
|
+
on: function (editor, event, handler) {
|
|
1549
|
+
var _a
|
|
1550
|
+
if (event !== 'change') {
|
|
1551
|
+
return
|
|
1552
|
+
}
|
|
1553
|
+
var listeners =
|
|
1554
|
+
(_a = CURSOR_CHANGE_EVENT_LISTENERS.get(editor)) !== null && _a !== void 0 ? _a : new Set()
|
|
1555
|
+
listeners.add(handler)
|
|
1556
|
+
if (editor) CURSOR_CHANGE_EVENT_LISTENERS.set(editor, listeners)
|
|
1557
|
+
},
|
|
1558
|
+
off: function (editor, event, listener) {
|
|
1559
|
+
if (event !== 'change') {
|
|
1560
|
+
return
|
|
1561
|
+
}
|
|
1562
|
+
var listeners = CURSOR_CHANGE_EVENT_LISTENERS.get(editor)
|
|
1563
|
+
if (listeners) {
|
|
1564
|
+
listeners.delete(listener)
|
|
1565
|
+
}
|
|
1566
|
+
},
|
|
1567
|
+
cursorState: function (editor, clientId) {
|
|
1568
|
+
var _a
|
|
1569
|
+
if (clientId === editor.awareness.clientID || !YjsEditor.connected(editor)) {
|
|
1570
|
+
return null
|
|
1571
|
+
}
|
|
1572
|
+
var state = editor.awareness.getStates().get(clientId)
|
|
1573
|
+
if (!state) {
|
|
1574
|
+
return null
|
|
1575
|
+
}
|
|
1576
|
+
return {
|
|
1577
|
+
relativeSelection:
|
|
1578
|
+
(_a = state[editor.selectionStateField]) !== null && _a !== void 0 ? _a : null,
|
|
1579
|
+
data: state[editor.cursorDataField],
|
|
1580
|
+
clientId: clientId,
|
|
1581
|
+
}
|
|
1582
|
+
},
|
|
1583
|
+
cursorStates: function (editor) {
|
|
1584
|
+
if (!YjsEditor.connected(editor)) {
|
|
1585
|
+
return {}
|
|
1586
|
+
}
|
|
1587
|
+
return Object.fromEntries(
|
|
1588
|
+
Array.from(editor.awareness.getStates().entries(), function (_a) {
|
|
1589
|
+
var _b = __read(_a, 2),
|
|
1590
|
+
id = _b[0],
|
|
1591
|
+
state = _b[1]
|
|
1592
|
+
// Ignore own state
|
|
1593
|
+
if (id === editor.awareness.clientID || !state) {
|
|
1594
|
+
return null
|
|
1595
|
+
}
|
|
1596
|
+
return [
|
|
1597
|
+
id,
|
|
1598
|
+
{
|
|
1599
|
+
relativeSelection: state[editor.selectionStateField],
|
|
1600
|
+
data: state[editor.cursorDataField],
|
|
1601
|
+
},
|
|
1602
|
+
]
|
|
1603
|
+
}).filter(Array.isArray)
|
|
1604
|
+
)
|
|
1605
|
+
},
|
|
1606
|
+
}
|
|
1607
|
+
function withCursors(awareness, options) {
|
|
1608
|
+
if (options === void 0) {
|
|
1609
|
+
options = {}
|
|
1610
|
+
}
|
|
1611
|
+
return function (editor) {
|
|
1612
|
+
var _a = options.cursorStateField,
|
|
1613
|
+
selectionStateField = _a === void 0 ? 'selection' : _a,
|
|
1614
|
+
_b = options.cursorDataField,
|
|
1615
|
+
cursorDataField = _b === void 0 ? 'data' : _b,
|
|
1616
|
+
_c = options.autoSend,
|
|
1617
|
+
autoSend = _c === void 0 ? true : _c,
|
|
1618
|
+
data = options.data
|
|
1619
|
+
var e = editor
|
|
1620
|
+
e.awareness = awareness
|
|
1621
|
+
e.cursorDataField = cursorDataField
|
|
1622
|
+
e.selectionStateField = selectionStateField
|
|
1623
|
+
e.sendCursorData = function (cursorData) {
|
|
1624
|
+
e.awareness.setLocalStateField(e.cursorDataField, cursorData)
|
|
1625
|
+
}
|
|
1626
|
+
e.sendCursorPosition = function (range) {
|
|
1627
|
+
var localState = e.awareness.getLocalState()
|
|
1628
|
+
var currentRange =
|
|
1629
|
+
localState === null || localState === void 0 ? void 0 : localState[selectionStateField]
|
|
1630
|
+
if (!range) {
|
|
1631
|
+
if (currentRange) {
|
|
1632
|
+
e.awareness.setLocalStateField(e.selectionStateField, null)
|
|
1633
|
+
}
|
|
1634
|
+
return
|
|
1635
|
+
}
|
|
1636
|
+
var _a = slateRangeToRelativeRange(e.sharedRoot, e, range),
|
|
1637
|
+
anchor = _a.anchor,
|
|
1638
|
+
focus = _a.focus
|
|
1639
|
+
if (
|
|
1640
|
+
!currentRange ||
|
|
1641
|
+
!Y.compareRelativePositions(anchor, currentRange) ||
|
|
1642
|
+
!Y.compareRelativePositions(focus, currentRange)
|
|
1643
|
+
) {
|
|
1644
|
+
e.awareness.setLocalStateField(e.selectionStateField, { anchor: anchor, focus: focus })
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
var awarenessChangeListener = function (yEvent) {
|
|
1648
|
+
var listeners = CURSOR_CHANGE_EVENT_LISTENERS.get(e)
|
|
1649
|
+
if (!listeners) {
|
|
1650
|
+
return
|
|
1651
|
+
}
|
|
1652
|
+
var localId = e.awareness.clientID
|
|
1653
|
+
var event = {
|
|
1654
|
+
added: yEvent.added.filter(function (id) {
|
|
1655
|
+
return id !== localId
|
|
1656
|
+
}),
|
|
1657
|
+
removed: yEvent.removed.filter(function (id) {
|
|
1658
|
+
return id !== localId
|
|
1659
|
+
}),
|
|
1660
|
+
updated: yEvent.updated.filter(function (id) {
|
|
1661
|
+
return id !== localId
|
|
1662
|
+
}),
|
|
1663
|
+
}
|
|
1664
|
+
if (event.added.length > 0 || event.removed.length > 0 || event.updated.length > 0) {
|
|
1665
|
+
listeners.forEach(function (listener) {
|
|
1666
|
+
return listener(event)
|
|
1667
|
+
})
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
var connect = e.connect,
|
|
1671
|
+
disconnect = e.disconnect
|
|
1672
|
+
e.connect = function () {
|
|
1673
|
+
connect()
|
|
1674
|
+
e.awareness.on('change', awarenessChangeListener)
|
|
1675
|
+
awarenessChangeListener({
|
|
1676
|
+
removed: [],
|
|
1677
|
+
added: Array.from(e.awareness.getStates().keys()),
|
|
1678
|
+
updated: [],
|
|
1679
|
+
})
|
|
1680
|
+
if (autoSend) {
|
|
1681
|
+
if (data) {
|
|
1682
|
+
CursorEditor.sendCursorData(e, data)
|
|
1683
|
+
}
|
|
1684
|
+
var onChange_1 = e.onChange
|
|
1685
|
+
e.onChange = function () {
|
|
1686
|
+
onChange_1()
|
|
1687
|
+
if (YjsEditor.connected(e)) {
|
|
1688
|
+
CursorEditor.sendCursorPosition(e)
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
e.disconnect = function () {
|
|
1694
|
+
e.awareness.off('change', awarenessChangeListener)
|
|
1695
|
+
awarenessChangeListener({
|
|
1696
|
+
removed: Array.from(e.awareness.getStates().keys()),
|
|
1697
|
+
added: [],
|
|
1698
|
+
updated: [],
|
|
1699
|
+
})
|
|
1700
|
+
disconnect()
|
|
1701
|
+
}
|
|
1702
|
+
return e
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
export {
|
|
1707
|
+
CursorEditor,
|
|
1708
|
+
YHistoryEditor,
|
|
1709
|
+
YjsEditor,
|
|
1710
|
+
relativePositionToSlatePoint,
|
|
1711
|
+
relativeRangeToSlateRange,
|
|
1712
|
+
slateNodesToInsertDelta,
|
|
1713
|
+
slatePointToRelativePosition,
|
|
1714
|
+
slateRangeToRelativeRange,
|
|
1715
|
+
withCursors,
|
|
1716
|
+
withYHistory,
|
|
1717
|
+
withYjs,
|
|
1718
|
+
yTextToSlateElement,
|
|
1719
|
+
}
|