@yoopta/editor 4.8.3-rc.0 → 4.8.4-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"shortcuts.d.ts","sourceRoot":"","sources":["../../src/extensions/shortcuts.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAgB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEvE,eAAO,MAAM,aAAa,WAAY,SAAS,SAAS,WAAW,gBA4ClE,CAAC"}
1
+ {"version":3,"file":"shortcuts.d.ts","sourceRoot":"","sources":["../../src/extensions/shortcuts.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAgB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEvE,eAAO,MAAM,aAAa,WAAY,SAAS,SAAS,WAAW,gBA6ClE,CAAC"}
package/dist/index.js CHANGED
@@ -10,4 +10,4 @@ var qo=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[hr
10
10
  * Copyright (c) 2014-2017, Jon Schlinkert.
11
11
  * Released under the MIT License.
12
12
  */
13
- function Zl(e){return"[object Object]"===Object.prototype.toString.call(e)}var Gl={isHistory(e){return!1!==Zl(t=e)&&(void 0===(n=t.constructor)||!1!==Zl(o=n.prototype)&&!1!==o.hasOwnProperty("isPrototypeOf"))&&Array.isArray(e.redos)&&Array.isArray(e.undos)&&(0===e.redos.length||_.isOperationList(e.redos[0].operations))&&(0===e.undos.length||_.isOperationList(e.undos[0].operations));var t,n,o}},Jl=new WeakMap,Ql=new WeakMap,ec={isHistoryEditor:e=>Gl.isHistory(e.history)&&S.isEditor(e),isMerging:e=>Ql.get(e),isSaving:e=>Jl.get(e),redo(e){e.redo()},undo(e){e.undo()},withoutMerging(e,t){var n=ec.isMerging(e);Ql.set(e,!1),t(),Ql.set(e,n)},withoutSaving(e,t){var n=ec.isSaving(e);Jl.set(e,!1),t(),Jl.set(e,n)}},tc=e=>{var t=e,{apply:n}=t;return t.history={undos:[],redos:[]},t.redo=()=>{var{history:e}=t,{redos:n}=e;if(n.length>0){var o=n[n.length-1];o.selectionBefore&&D.setSelection(t,o.selectionBefore),ec.withoutSaving(t,(()=>{S.withoutNormalizing(t,(()=>{for(var e of o.operations)t.apply(e)}))})),e.redos.pop(),t.writeHistory("undos",o)}},t.undo=()=>{var{history:e}=t,{undos:n}=e;if(n.length>0){var o=n[n.length-1];ec.withoutSaving(t,(()=>{S.withoutNormalizing(t,(()=>{var e=o.operations.map(_.inverse).reverse();for(var n of e)t.apply(n);o.selectionBefore&&D.setSelection(t,o.selectionBefore)}))})),t.writeHistory("redos",o),e.undos.pop()}},t.apply=e=>{var{operations:o,history:r}=t,{undos:i}=r,l=i[i.length-1],c=l&&l.operations[l.operations.length-1],a=ec.isSaving(t),s=ec.isMerging(t);if(null==a&&(a=oc(e)),a){if(null==s&&(s=null!=l&&(0!==o.length||nc(e,c))),l&&s)l.operations.push(e);else{var d={operations:[e],selectionBefore:t.selection};t.writeHistory("undos",d)}for(;i.length>100;)i.shift();r.redos=[]}n(e)},t.writeHistory=(e,n)=>{t.history[e].push(n)},t},nc=(e,t)=>!(!t||"insert_text"!==e.type||"insert_text"!==t.type||e.offset!==t.offset+t.text.length||!j.equals(e.path,t.path))||!(!t||"remove_text"!==e.type||"remove_text"!==t.type||e.offset+e.text.length!==t.offset||!j.equals(e.path,t.path)),oc=(e,t)=>"set_selection"!==e.type;const rc=(e,t)=>{const{insertText:n}=t;return t.insertText=o=>{var r;const{selection:i}=t;if(" "===o&&i&&B.isCollapsed(i)){const{anchor:l}=i,c=S.above(t,{match:e=>A.isElement(e)&&S.isBlock(t,e),mode:"lowest"});if(!c)return;const[,a]=c,s=S.parent(t,a),[d]=s;if(A.isElement(d)&&!R.isText(d.children[0]))return n(o);const u=c?a:[],f={anchor:l,focus:S.start(t,u)},p=S.string(t,f),h=null===(r=e.shortcuts)||void 0===r?void 0:r[p];if(!!h&&!h.isActive())return D.select(t,f),D.delete(t),void Ec.createBlock(e,h.type,{deleteText:!1,focus:!0})}n(o)},t};function ic(e){return rc(e,tc(C(T())))}function lc(e,t,n={}){e.children=Xl(e.children);const{at:o=null,focus:r=!1,slate:i=null}=n,l=P(e),c=e.plugins[t.type].events||{},{onCreate:a}=c,s=o,d={id:G(),value:t.value,type:t.type,meta:Object.assign(Object.assign({},t.meta),{order:0})};let u=!1;if(i&&i.selection){const e=S.string(i,i.selection.anchor.path);u=S.isStart(i,i.selection.anchor,i.selection.anchor.path)&&e.length>0}if(s){const[t]=s;Object.values(e.children).forEach((e=>{e.meta.order>=t&&(e.meta.order+=1)})),d.meta.order=t}else{const t=Object.keys(e.children).length;d.meta.order=t}const f=ic(e);e.blockEditorsMap[d.id]=f,u&&l&&(d.meta.order=l.meta.order,l.meta.order+=1),e.children[d.id]=d;const p=null==l?void 0:l.id;e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),null==a||a(e,d.id),r&&e.focusBlock(u&&p?p:d.id)}function cc(e,t={}){const{at:n=e.selection,deleteAll:o=!1,fromPaths:r,focus:i}=t;if(Array.isArray(r)&&r.length>0){e.children=Xl(e.children),r.forEach((t=>{const n=P(e,{at:[t]});if(n){const t=e.plugins[n.type].events||{},{onDestroy:o}=t;null==o||o(e,n.id),delete e.children[n.id],delete e.blockEditorsMap[n.id]}}));return Object.keys(e.children).forEach(((t,n)=>{e.children[t].meta.order=n})),e.children=ql(e.children),e.applyChanges(),void e.emit("change",e.children)}if(o||1===Object.keys(e.children).length){e.children={},e.blockEditorsMap={};const t=Q({id:G()}),n=ic(e);return e.children[t.id]=t,e.blockEditorsMap[t.id]=n,e.setSelection([0]),e.setBlockSelected(null),e.focusBlock(t.id,{slate:n,waitExecution:!0}),e.applyChanges(),void e.emit("change",e.children)}if(!n)return;e.children=Xl(e.children);const[l]=n,c=Object.keys(e.children),a=c.find((t=>e.children[t].meta.order===l));if(c.forEach((t=>{const n=e.children[t];n.meta.order>l&&(n.meta.order-=1)})),a){const t=e.children[a],n=e.plugins[t.type].events||{},{onDestroy:o}=n;null==o||o(e,a),delete e.children[a],delete e.blockEditorsMap[a]}if(e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),i){const n=e.selection?e.selection[0]-1:0,o=P(e,{at:[n]});o&&e.focusBlock(o.id,{focusAt:t.focusAt})}}function ac(e,t={}){const{deleteAll:n=!1,paths:o,blockIds:r,focus:i=!0}=t;if(n||1===Object.keys(e.children).length){e.children={},e.blockEditorsMap={};const t=Q({id:G()}),n=ic(e);return e.children[t.id]=t,e.blockEditorsMap[t.id]=n,e.setSelection([0]),e.applyChanges(),e.emit("change",e.children),void(i&&e.focusBlock(t.id,{waitExecution:!0}))}if(Array.isArray(r)&&r.length>0){e.children=Xl(e.children),r.forEach((t=>{delete e.children[t],delete e.blockEditorsMap[t]}));const t=Object.keys(e.children).sort(((t,n)=>e.children[t].meta.order>e.children[n].meta.order?1:-1));return t.forEach(((t,n)=>{e.children[t].meta.order=n})),e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),void(i&&e.focusBlock(t[0],{waitExecution:!0}))}if(Array.isArray(o)&&o.length>0){e.children=Xl(e.children),o.forEach((t=>{const n=P(e,{at:[t]});n&&(delete e.children[n.id],delete e.blockEditorsMap[n.id])}));const t=Object.keys(e.children).sort(((t,n)=>e.children[t].meta.order>e.children[n].meta.order?1:-1));return t.forEach(((t,n)=>{e.children[t].meta.order=n})),e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),void(i&&e.focusBlock(t[0],{waitExecution:!0}))}}function sc(e,t,n){e.children=Xl(e.children);const[o]=n,r=e.children[t],i=Object.values(e.children).find((e=>e.meta.order===o)),l=r.meta.order<i.meta.order,c=r.meta.order>i.meta.order;Object.values(e.children).forEach((e=>{l?e.meta.order>r.meta.order&&e.meta.order<=i.meta.order&&e.meta.order--:c&&e.meta.order<r.meta.order&&e.meta.order>=i.meta.order&&e.meta.order++})),r.meta.order=o,r.meta.depth=i.meta.depth,e.setSelection([o]),e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children)}function dc(e,t,n={}){try{const{focusAt:o,waitExecution:r=!0,waitExecutionMs:i=0,shouldUpdateBlockSelection:l=!0}=n,c=()=>{const r=n.slate||e.blockEditorsMap[t],i=e.children[t];if(!r||!i)return;if(!e.blocks[i.type].hasCustomEditor){const e=function(e,t){if(M.isPoint(t))return t;if(j.isPath(t))return{path:t,offset:0};const[,n]=S.first(e,[0]);return{path:n||[0,0],offset:0}}(r,o);D.select(r,e),w.focus(r)}l&&setTimeout((()=>{e.setSelection([i.meta.order])}),0)};r?setTimeout((()=>c()),i):c(),Hi.set(e,!0)}catch(e){}}function uc(e,t={}){const{slate:n,focus:o=!0}=t,r=P(e);n&&n.selection&&r&&S.withoutNormalizing(n,(()=>{e.children=Xl(e.children);const t=j.parent(n.selection.anchor.path);D.splitNodes(n,{at:n.selection,match:e=>A.isElement(e),always:!0,mode:"highest"});const i=t[0]+1,l=n.children.slice()[i];D.removeNodes(n,{at:[i],match:e=>A.isElement(e),mode:"highest"});const c={id:G(),type:r.type,meta:{order:r.meta.order+1,depth:r.meta.depth,align:r.meta.align},value:[l]};Object.values(e.children).forEach((e=>{e.meta.order>=c.meta.order&&(e.meta.order+=1)}));const a=ic(e);e.blockEditorsMap[c.id]=a,e.children[c.id]=c,e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),o&&e.focusBlock(c.id,{slate:a})}))}function fc(e,t={}){const{at:n=e.selection,blockId:o=""}=t;if(!o&&!n)return;e.children=Xl(e.children);const r=e.children[o]||P(e);r&&(r.meta.depth=r.meta.depth+1,e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children))}function pc(e,t={}){const{at:n=e.selection,blockId:o=""}=t;if(!o&&!n)return;e.children=Xl(e.children);const r=e.children[o]||P(e);r&&(r.meta.depth=0===r.meta.depth?0:r.meta.depth-1,e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children))}var hc={};!function(e,t){var n="__lodash_hash_undefined__",o=9007199254740991,r="[object Arguments]",i="[object Boolean]",l="[object Date]",c="[object Function]",a="[object GeneratorFunction]",s="[object Map]",d="[object Number]",u="[object Object]",f="[object Promise]",p="[object RegExp]",h="[object Set]",g="[object String]",v="[object Symbol]",m="[object WeakMap]",y="[object ArrayBuffer]",b="[object DataView]",w="[object Float32Array]",x="[object Float64Array]",k="[object Int8Array]",E="[object Int16Array]",O="[object Int32Array]",C="[object Uint8Array]",S="[object Uint8ClampedArray]",D="[object Uint16Array]",j="[object Uint32Array]",B=/\w*$/,R=/^\[object .+?Constructor\]$/,A=/^(?:0|[1-9]\d*)$/,_={};_[r]=_["[object Array]"]=_[y]=_[b]=_[i]=_[l]=_[w]=_[x]=_[k]=_[E]=_[O]=_[s]=_[d]=_[u]=_[p]=_[h]=_[g]=_[v]=_[C]=_[S]=_[D]=_[j]=!0,_["[object Error]"]=_[c]=_[m]=!1;var N="object"==typeof Y&&Y&&Y.Object===Object&&Y,T="object"==typeof self&&self&&self.Object===Object&&self,M=N||T||Function("return this")(),L=t&&!t.nodeType&&t,P=L&&e&&!e.nodeType&&e,I=P&&P.exports===L;function z(e,t){return e.set(t[0],t[1]),e}function F(e,t){return e.add(t),e}function $(e,t,n,o){var r=-1,i=e?e.length:0;for(o&&i&&(n=e[++r]);++r<i;)n=t(n,e[r],r,e);return n}function H(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function U(e){var t=-1,n=Array(e.size);return e.forEach((function(e,o){n[++t]=[o,e]})),n}function V(e,t){return function(n){return e(t(n))}}function K(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var W,X=Array.prototype,q=Function.prototype,Z=Object.prototype,G=M["__core-js_shared__"],J=(W=/[^.]+$/.exec(G&&G.keys&&G.keys.IE_PROTO||""))?"Symbol(src)_1."+W:"",Q=q.toString,ee=Z.hasOwnProperty,te=Z.toString,ne=RegExp("^"+Q.call(ee).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),oe=I?M.Buffer:void 0,re=M.Symbol,ie=M.Uint8Array,le=V(Object.getPrototypeOf,Object),ce=Object.create,ae=Z.propertyIsEnumerable,se=X.splice,de=Object.getOwnPropertySymbols,ue=oe?oe.isBuffer:void 0,fe=V(Object.keys,Object),pe=Ie(M,"DataView"),he=Ie(M,"Map"),ge=Ie(M,"Promise"),ve=Ie(M,"Set"),me=Ie(M,"WeakMap"),ye=Ie(Object,"create"),be=Ue(pe),we=Ue(he),xe=Ue(ge),ke=Ue(ve),Ee=Ue(me),Oe=re?re.prototype:void 0,Ce=Oe?Oe.valueOf:void 0;function Se(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function De(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function je(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function Be(e){this.__data__=new De(e)}function Re(e,t){var n=Ke(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&We(e)}(e)&&ee.call(e,"callee")&&(!ae.call(e,"callee")||te.call(e)==r)}(e)?function(e,t){for(var n=-1,o=Array(e);++n<e;)o[n]=t(n);return o}(e.length,String):[],o=n.length,i=!!o;for(var l in e)!t&&!ee.call(e,l)||i&&("length"==l||$e(l,o))||n.push(l);return n}function Ae(e,t,n){var o=e[t];ee.call(e,t)&&Ve(o,n)&&(void 0!==n||t in e)||(e[t]=n)}function _e(e,t){for(var n=e.length;n--;)if(Ve(e[n][0],t))return n;return-1}function Ne(e,t,n,o,f,m,R){var A;if(o&&(A=m?o(e,f,m,R):o(e)),void 0!==A)return A;if(!qe(e))return e;var N=Ke(e);if(N){if(A=function(e){var t=e.length,n=e.constructor(t);t&&"string"==typeof e[0]&&ee.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!t)return function(e,t){var n=-1,o=e.length;t||(t=Array(o));for(;++n<o;)t[n]=e[n];return t}(e,A)}else{var T=Fe(e),M=T==c||T==a;if(Ye(e))return function(e,t){if(t)return e.slice();var n=new e.constructor(e.length);return e.copy(n),n}(e,t);if(T==u||T==r||M&&!m){if(H(e))return m?e:{};if(A=function(e){return"function"!=typeof e.constructor||He(e)?{}:(t=le(e),qe(t)?ce(t):{});var t}(M?{}:e),!t)return function(e,t){return Le(e,ze(e),t)}(e,function(e,t){return e&&Le(t,Ze(t),e)}(A,e))}else{if(!_[T])return m?e:{};A=function(e,t,n,o){var r=e.constructor;switch(t){case y:return Me(e);case i:case l:return new r(+e);case b:return function(e,t){var n=t?Me(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,o);case w:case x:case k:case E:case O:case C:case S:case D:case j:return function(e,t){var n=t?Me(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}(e,o);case s:return function(e,t,n){var o=t?n(U(e),!0):U(e);return $(o,z,new e.constructor)}(e,o,n);case d:case g:return new r(e);case p:return function(e){var t=new e.constructor(e.source,B.exec(e));return t.lastIndex=e.lastIndex,t}(e);case h:return function(e,t,n){var o=t?n(K(e),!0):K(e);return $(o,F,new e.constructor)}(e,o,n);case v:return c=e,Ce?Object(Ce.call(c)):{}}var c}(e,T,Ne,t)}}R||(R=new Be);var L=R.get(e);if(L)return L;if(R.set(e,A),!N)var P=n?function(e){return function(e,t,n){var o=t(e);return Ke(e)?o:function(e,t){for(var n=-1,o=t.length,r=e.length;++n<o;)e[r+n]=t[n];return e}(o,n(e))}(e,Ze,ze)}(e):Ze(e);return function(e,t){for(var n=-1,o=e?e.length:0;++n<o&&!1!==t(e[n],n,e););}(P||e,(function(r,i){P&&(r=e[i=r]),Ae(A,i,Ne(r,t,n,o,i,e,R))})),A}function Te(e){return!(!qe(e)||(t=e,J&&J in t))&&(Xe(e)||H(e)?ne:R).test(Ue(e));var t}function Me(e){var t=new e.constructor(e.byteLength);return new ie(t).set(new ie(e)),t}function Le(e,t,n,o){n||(n={});for(var r=-1,i=t.length;++r<i;){var l=t[r],c=o?o(n[l],e[l],l,n,e):void 0;Ae(n,l,void 0===c?e[l]:c)}return n}function Pe(e,t){var n,o,r=e.__data__;return("string"==(o=typeof(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?r["string"==typeof t?"string":"hash"]:r.map}function Ie(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Te(n)?n:void 0}Se.prototype.clear=function(){this.__data__=ye?ye(null):{}},Se.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Se.prototype.get=function(e){var t=this.__data__;if(ye){var o=t[e];return o===n?void 0:o}return ee.call(t,e)?t[e]:void 0},Se.prototype.has=function(e){var t=this.__data__;return ye?void 0!==t[e]:ee.call(t,e)},Se.prototype.set=function(e,t){return this.__data__[e]=ye&&void 0===t?n:t,this},De.prototype.clear=function(){this.__data__=[]},De.prototype.delete=function(e){var t=this.__data__,n=_e(t,e);return!(n<0)&&(n==t.length-1?t.pop():se.call(t,n,1),!0)},De.prototype.get=function(e){var t=this.__data__,n=_e(t,e);return n<0?void 0:t[n][1]},De.prototype.has=function(e){return _e(this.__data__,e)>-1},De.prototype.set=function(e,t){var n=this.__data__,o=_e(n,e);return o<0?n.push([e,t]):n[o][1]=t,this},je.prototype.clear=function(){this.__data__={hash:new Se,map:new(he||De),string:new Se}},je.prototype.delete=function(e){return Pe(this,e).delete(e)},je.prototype.get=function(e){return Pe(this,e).get(e)},je.prototype.has=function(e){return Pe(this,e).has(e)},je.prototype.set=function(e,t){return Pe(this,e).set(e,t),this},Be.prototype.clear=function(){this.__data__=new De},Be.prototype.delete=function(e){return this.__data__.delete(e)},Be.prototype.get=function(e){return this.__data__.get(e)},Be.prototype.has=function(e){return this.__data__.has(e)},Be.prototype.set=function(e,t){var n=this.__data__;if(n instanceof De){var o=n.__data__;if(!he||o.length<199)return o.push([e,t]),this;n=this.__data__=new je(o)}return n.set(e,t),this};var ze=de?V(de,Object):function(){return[]},Fe=function(e){return te.call(e)};function $e(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||A.test(e))&&e>-1&&e%1==0&&e<t}function He(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Z)}function Ue(e){if(null!=e){try{return Q.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ve(e,t){return e===t||e!=e&&t!=t}(pe&&Fe(new pe(new ArrayBuffer(1)))!=b||he&&Fe(new he)!=s||ge&&Fe(ge.resolve())!=f||ve&&Fe(new ve)!=h||me&&Fe(new me)!=m)&&(Fe=function(e){var t=te.call(e),n=t==u?e.constructor:void 0,o=n?Ue(n):void 0;if(o)switch(o){case be:return b;case we:return s;case xe:return f;case ke:return h;case Ee:return m}return t});var Ke=Array.isArray;function We(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=o}(e.length)&&!Xe(e)}var Ye=ue||function(){return!1};function Xe(e){var t=qe(e)?te.call(e):"";return t==c||t==a}function qe(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ze(e){return We(e)?Re(e):function(e){if(!He(e))return fe(e);var t=[];for(var n in Object(e))ee.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return Ne(e,!0,!0)}}({get exports(){return hc},set exports(e){hc=e}},hc);var gc=hc;function vc(e,t={}){const{blockId:n,focus:o}=t;if(!n&&!t.at)throw new Error("blockId or path should be provided");let r=null;if(n&&(r=e.children[n],!r))throw new Error(`Block not with blockId: ${n} found`);if(t.at&&(r=P(e,{at:t.at}),!r))throw new Error(`Block in path ${t.at} not found`);if(!r)throw new Error("Block not found");e.children=Xl(e.children);Object.values(e.children).forEach((e=>{e.meta.order>r.meta.order&&(e.meta.order+=1)}));const i=(l=r,"function"==typeof window.structuredClone?window.structuredClone(l):gc(l));var l;const c=ic(e);i.id=G(),i.meta.order=r.meta.order+1,e.children[i.id]=i,e.blockEditorsMap[i.id]=c;const a=i.id;e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),o&&e.focusBlock(a,{waitExecution:!0})}function mc(e,t,n){e.children=Xl(e.children);let o=!1;const r=e.children[t];r&&(n.id&&(r.id=n.id,o=!0),n.type&&(r.type=n.type,o=!0),n.meta&&(r.meta=n.meta,o=!0),n.value&&(r.value=n.value),e.children=ql(e.children),o&&e.applyChanges(),e.emit("change",e.children))}const yc="Paragraph";function bc(e,t,n){e.children=Xl(e.children);const o=P(e,{at:(null==n?void 0:n.at)||e.selection});if(!o)throw new Error("Block from not found at current selection");let r=t;o.type===r&&(r=yc);const i=Ln(e,{at:[o.meta.order]});if(!i)throw new Error(`Slate not found for block in position ${o.meta.order}`);const l=ri(e.blocks[r].elements);S.withoutNormalizing(i,(()=>{D.setNodes(i,{type:l},{at:i.selection||[0],mode:"lowest",match:e=>A.isElement(e)&&!S.isInline(i,e)}),(null==n?void 0:n.deleteText)&&D.delete(i,{at:[0,0]});const t={id:G(),type:r,meta:Object.assign(Object.assign({},o.meta),{order:o.meta.order}),value:i.children},c=ic(e);c.children=i.children,delete e.children[o.id],delete e.blockEditorsMap[o.id],e.blockEditorsMap[t.id]=c,e.children[t.id]=t,t.value=c.children,e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),(null==n?void 0:n.focus)&&e.focusBlock(t.id,{slate:c})}))}function wc(e,t,n={}){e.children=Xl(e.children);const{at:o,focus:r}=n;let i=o||[0];const l=P(e),c=Ln(e);let a=!1,s=!1;if(c&&c.selection){const t=j.parent(c.selection.anchor.path),n=S.string(c,t).trim(),o=S.isStart(c,c.selection.anchor,t);a=""===n&&o,s=!o||n.length>0,w.blur(c),e.setSelection(null)}s&&(i=[i[0]+1]),Object.values(e.children).forEach((e=>{e.meta.order>=i[0]&&(e.meta.order+=t.length)}));const d=[];if(t.forEach(((t,n)=>{const o={id:t.id,value:t.value,type:t.type,meta:Object.assign(Object.assign({},t.meta),{order:i[0]+n})};d.push(o.meta.order),e.children[o.id]=o;const r=ic(e);e.blockEditorsMap[o.id]=r})),l&&a){const t=l.meta.order;delete e.children[l.id],delete e.blockEditorsMap[l.id],Object.keys(e.children).forEach((n=>{const o=e.children[n];o.meta.order>t&&(o.meta.order-=1)}))}e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),r&&e.setBlockSelected(d)}function xc(e,t,n){e.children=Xl(e.children);const o=P(e);if(!o)throw new Error(`No fromBlock found in the current selection path. Passed path: ${e.selection}`);const r=(null==n?void 0:n.slate)||Ln(e,{at:[null==o?void 0:o.meta.order]});if(!r||!r.selection)return;const i=e.blocks[t],l=Q({id:G(),type:i.type,meta:{order:o.meta.order,depth:o.meta.depth,align:o.meta.align}}),c=e.plugins[t].events||{},{onBeforeCreate:a,onCreate:s}=c,d="function"==typeof a?a(e,l.id):ci(e,t);(null==n?void 0:n.deleteText)&&D.delete(r,{at:[0,0]});const u=ic(e);u.children=[d],delete e.children[o.id],delete e.blockEditorsMap[o.id],e.blockEditorsMap[l.id]=u,e.children[l.id]=l,l.value=u.children;const f=l.id;e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),null==s||s(e,l.id),(null==n?void 0:n.focus)&&e.focusBlock(f,{slate:u,waitExecution:!0})}function kc(e,t){if(!(null==t?void 0:t.id)&&!(null==t?void 0:t.at))throw new Error("getBlock requires either an id or at");if(null==t?void 0:t.id)return e.children[null==t?void 0:t.id];const n=Object.keys(e.children).find((n=>{var o;return e.children[n].meta.order===(null===(o=null==t?void 0:t.at)||void 0===o?void 0:o[0])}));return n?e.children[n]:null}const Ec={insertBlock:lc,deleteBlock:cc,moveBlock:sc,focusBlock:dc,splitBlock:uc,increaseBlockDepth:fc,decreaseBlockDepth:pc,duplicateBlock:vc,updateBlock:mc,toggleBlock:bc,insertBlocks:wc,createBlock:xc,deleteBlocks:ac,getBlock:kc,getSlate:function(e,t){if(!(null==t?void 0:t.id)&&!(null==t?void 0:t.at))throw new Error("getSlate requires either an id or at");const n=(null==t?void 0:t.id)||Object.keys(e.children).find((n=>{var o;return e.children[n].meta.order===(null===(o=null==t?void 0:t.at)||void 0===o?void 0:o[0])})),o=e.blockEditorsMap[n||""],r=e.children[n||""],i=e.blocks[(null==r?void 0:r.type)||""];if(!(null==i?void 0:i.hasCustomEditor)&&!o)throw new Error(`Slate not found with params: ${JSON.stringify(t)}`);return o}};function Oc({editor:e}){const t=c(!1),n=c(!1),o=c(null),r=c(null),i=t=>{const n=t||e.selection;if(n){const t=Ec.getSlate(e,{at:n});if(!t)return;S.withoutNormalizing(t,(()=>{D.select(t,[0]),t.selection&&B.isExpanded(t.selection)&&(w.blur(t),w.deselect(t))}))}},l=l=>{var c;if(!t.current||e.readOnly)return;const a=document.elementFromPoint(l.clientX,l.clientY),s=null==a?void 0:a.closest("[data-yoopta-block]");if(s){const t=s.getAttribute("data-yoopta-block-id")||"",l=null===(c=e.children[t])||void 0===c?void 0:c.meta.order;if(n.current&&"number"==typeof l&&l===o.current)return r.current=l,void e.setBlockSelected([l],{only:!0});if("number"==typeof l&&l!==r.current){r.current=l,n.current=!0;const t=Math.min(o.current,l),c=Math.max(o.current,l);i();const a=Array.from({length:c-t+1},((e,n)=>t+n));e.setBlockSelected(a)}}},a=()=>{var i,c;t.current=!1,n.current=!1,o.current=null,r.current=null,null===(i=e.refElement)||void 0===i||i.removeEventListener("mousemove",l),null===(c=e.refElement)||void 0===c||c.removeEventListener("mouseup",a)};return{onMouseDown:n=>{var c,s,d,u,f;if(e.readOnly)return;Array.isArray(e.selectedBlocks)&&e.selectedBlocks.length>0&&!n.shiftKey&&!n.altKey&&e.setBlockSelected(null);const p=n.target.closest("[data-yoopta-block]");if(p&&0===n.button){const h=p.getAttribute("data-yoopta-block-id")||"",g=null===(c=e.children[h])||void 0===c?void 0:c.meta.order;if("number"==typeof g){if(t.current=!0,o.current=g,r.current=g,n.shiftKey&&Array.isArray(e.selection)&&g!==(null===(s=e.selection)||void 0===s?void 0:s[0]))return void(t=>{i();const n=e.selection[0],o=Array.from({length:Math.abs(t-n)}).map(((e,o)=>t>n?n+o+1:n-o-1));e.setBlockSelected([...o,n],{only:!0}),e.setSelection([t])})(g);g!==(null===(d=e.selection)||void 0===d?void 0:d[0])&&e.setSelection([g]),null===(u=e.refElement)||void 0===u||u.addEventListener("mousemove",l),null===(f=e.refElement)||void 0===f||f.addEventListener("mouseup",a)}}}}}const Cc={selectionStarted:!1,indexToSelect:null,startedIndexToSelect:null},Sc=({placeholder:n,marks:o,className:r,selectionBoxRoot:i,width:l,style:a,children:d,autoFocus:u=!0})=>{const f=$(),p=V(),h=rl({editor:f,root:i}),g=Oc({editor:f});let v=c(Cc).current;s((()=>{u&&!p&&f.focus()}),[u,p]),s((()=>{if(!p)return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)}),[f.selectedBlocks,p]);const m=()=>{v.indexToSelect=null,v.startedIndexToSelect=null,v.selectionStarted=!1},y=e=>{var t,n,o,r,i;if(!p){if(zi.isSelect(e)){if((null===(t=f.selectedBlocks)||void 0===t?void 0:t.length)===Object.keys(f.children).length)return void e.preventDefault();if(v.selectionStarted)return e.preventDefault(),void f.setBlockSelected([],{allSelected:!0})}if((zi.isCopy(e)||zi.isCut(e))&&Array.isArray(f.selectedBlocks)&&f.selectedBlocks.length>0){e.preventDefault();const t=f.getHTML(f.getEditorValue()),n=f.getPlainText(f.getEditorValue()),o=new Blob([t],{type:"text/html"}),r=new Blob([n],{type:"text/plain"}),i=new ClipboardItem({"text/html":o,"text/plain":r});if(navigator.clipboard.write([i]).then((()=>{const e=(new DOMParser).parseFromString(t,"text/html");console.log("HTML copied\n",e.body)})),zi.isCut(e)){const e=f.selectedBlocks.length===Object.keys(f.children).length;f.deleteBlocks({paths:f.selectedBlocks,focus:!1}),f.setBlockSelected(null),m(),e&&f.insertBlock(Q({id:G()}),{at:[0],focus:!0})}}else{if(zi.isBackspace(e)){e.stopPropagation();if(Array.isArray(f.selectedBlocks)&&(null===(n=f.selectedBlocks)||void 0===n?void 0:n.length)===Object.keys(f.children).length)return e.preventDefault(),f.deleteBlocks({deleteAll:!0}),f.setBlockSelected(null),void m();if(Array.isArray(f.selectedBlocks)&&(null===(o=f.selectedBlocks)||void 0===o?void 0:o.length)>0)return e.preventDefault(),f.deleteBlocks({paths:f.selectedBlocks,focus:!1}),f.setBlockSelected(null),void m()}if(zi.isShiftArrowUp(e)){if("function"==typeof e.isDefaultPrevented&&e.isDefaultPrevented())return;if(v.selectionStarted&&null!==v.startedIndexToSelect&&null!==v.indexToSelect){const e=v.indexToSelect,t=e-1;if(0===e)return;if(e===v.startedIndexToSelect)return f.setBlockSelected([t]),void(v.indexToSelect=t);if(t<v.startedIndexToSelect)return f.setBlockSelected([t]),void(v.indexToSelect=t);if((null===(r=f.selectedBlocks)||void 0===r?void 0:r.includes(e))&&e!==v.startedIndexToSelect){const n=f.selectedBlocks.filter((t=>t!==e));return f.setBlockSelected(n,{only:!0}),void(v.indexToSelect=t)}return}const t=P(f),n=Ln(f);if(!n||!n.selection||!t)return;const o=j.parent(n.selection.anchor.path),i=S.isStart(n,n.selection.focus,o);if(B.isExpanded(n.selection)&&i){const o=f.selection?[f.selection[0]-1]:[0],r=P(f,{at:o});t&&r&&(e.preventDefault(),w.blur(n),w.deselect(n),D.deselect(n),f.setSelection(null),f.setBlockSelected([null==t?void 0:t.meta.order,t.meta.order-1]),v.startedIndexToSelect=t.meta.order,v.indexToSelect=t.meta.order-1,v.selectionStarted=!0)}}if(zi.isShiftArrowDown(e)){if(v.selectionStarted&&null!==v.indexToSelect&&null!==v.startedIndexToSelect){const e=v.indexToSelect,t=e+1;if(t===Object.keys(f.children).length)return;if(e===v.startedIndexToSelect)return f.setBlockSelected([t]),void(v.indexToSelect=t);if(t>v.startedIndexToSelect)return f.setBlockSelected([t]),void(v.indexToSelect=t);if((null===(i=f.selectedBlocks)||void 0===i?void 0:i.includes(e))&&e!==v.startedIndexToSelect){const n=f.selectedBlocks.filter((t=>t!==e));return f.setBlockSelected(n,{only:!0}),void(v.indexToSelect=t)}return}const t=P(f),n=Ln(f);if(!n||!n.selection||!t)return;const o=j.parent(n.selection.anchor.path),r=S.isEnd(n,n.selection.focus,o);if(B.isExpanded(n.selection)&&r){const o=f.selection?[f.selection[0]+1]:[0],r=P(f,{at:o});t&&r&&(e.preventDefault(),w.blur(n),w.deselect(n),D.deselect(n),f.setSelection(null),f.setBlockSelected([null==t?void 0:t.meta.order,(null==t?void 0:t.meta.order)+1]),v.startedIndexToSelect=t.meta.order,v.indexToSelect=t.meta.order+1,v.selectionStarted=!0)}}if(zi.isTab(e)){const t=f.selectedBlocks;Array.isArray(t)&&t.length>0&&(e.preventDefault(),t.forEach((e=>{const t=Ec.getBlock(f,{at:[e]});f.increaseBlockDepth({blockId:null==t?void 0:t.id})})))}else if(zi.isShiftTab(e)){const t=f.selectedBlocks;Array.isArray(t)&&t.length>0&&(e.preventDefault(),t.forEach((e=>{const t=Ec.getBlock(f,{at:[e]});f.decreaseBlockDepth({blockId:null==t?void 0:t.id})})))}else;}}},b=e=>{if(!p)return;const t=e.clipboardData,n=window.getSelection();if(n&&n.rangeCount>0){const e=n.getRangeAt(0);if(e.collapsed)return;const o=e.cloneContents().querySelectorAll("[data-yoopta-block-id]");if(!o.length)return;const r=Array.from(o).reduce(((e,t)=>{const n=t.getAttribute("data-yoopta-block-id")||"",o=f.children[n];return o&&(e[n]=o),e}),{}),i=f.getHTML(r),l=f.getPlainText(r);return t.setData("text/html",i),void t.setData("text/plain",l)}},x=(k={userSelect:h.selection?"none":"auto",pointerEvents:h.selection?"none":"auto",width:l||(null==a?void 0:a.width),paddingBottom:null==a?void 0:a.paddingBottom},Object.assign(Object.assign({},k),{width:k.width||400,paddingBottom:"number"==typeof k.paddingBottom?k.paddingBottom:100}));var k;return t("div",Object.assign({ref:e=>f.refElement=e,className:r?`yoopta-editor ${r}`:"yoopta-editor",style:x,onMouseDown:e=>{p||(g.onMouseDown(e),m(),(e=>{var t;const n=f.refElement;if(!n)return;const{bottom:o}=n.getBoundingClientRect(),r=o-parseInt(getComputedStyle(n).paddingBottom,10),i=Q({id:G()});if(e.clientY>=r){const e=Object.keys(f.children).length-1,n=P(f,{at:[e]}),o=Ln(f,{at:[e]});if(n&&o&&o.selection){const e=S.string(o,o.selection.anchor.path),r=j.parent(o.selection.anchor.path),[l]=S.node(o,r);if(n.type===i.type&&A.isElement(l)&&"void"!==(null===(t=l.props)||void 0===t?void 0:t.nodeType)&&0===e.trim().length)return void f.focusBlock(n.id,{slate:o})}const r=e+1;f.insertBlock(i,{at:[r],focus:!0})}})(e))},onBlur:e=>{var t;(null===(t=f.refElement)||void 0===t?void 0:t.contains(e.relatedTarget))||p||(m(),Array.isArray(f.selectedBlocks)&&f.selectedBlocks.length>0&&f.setBlockSelected(null))},onCopy:b,onCut:b},{children:[e(ol,{editor:f,marks:o,placeholder:n}),!1!==i&&e(il,{origin:h.origin,coords:h.coords,isOpen:h.selection&&!p}),d]}))};function Dc(e,t){const n=Ln(e);if(!n)return!1;const o=S.marks(n);return!!(null==o?void 0:o[t])}function jc(e,t){const n={};return t.forEach((t=>{const o=t.type;n[o]={hotkey:t.hotkey,type:o,getValue:()=>function(e,t){const n=Ln(e);if(!n)return null;const o=S.marks(n);return null==o?void 0:o[t]}(e,o),isActive:()=>Dc(e,o),toggle:()=>function(e,t){const n=Ln(e),o=Dc(e,t);n&&(o?S.removeMark(n,t):S.addMark(n,t,!0),e.applyChanges(),e.emit("change",e.children))}(e,o),update:t=>function(e,t,n){const o=Ln(e);o&&o.selection&&B.isExpanded(o.selection)&&(S.addMark(o,t,n),e.applyChanges(),e.emit("change",e.children))}(e,o,t)}})),n}function Bc(e){const t={};return Object.keys(e.children).forEach((n=>{const o=ic(e);t[n]=o})),t}function Rc({type:e,hotkey:t,render:n}){return{type:e,hotkey:t,render:n}}const Ac=Rc({type:"fakeSelection",render:t=>e("span",Object.assign({style:{backgroundColor:"#d7e6fa"}},{children:t.children}))}),_c=(()=>{const e=G();return{[e]:Q({id:e})}})(),Nc=new q,Tc=(e,t)=>Nc.on(e,t),Mc=(e,t)=>Nc.once(e,t),Lc=(e,t)=>Nc.off(e,t),Pc=(e,t)=>Nc.emit(e,t);const Ic=({id:t,editor:n,value:o,marks:r,plugins:i,autoFocus:l,className:c,tools:a,selectionBoxRoot:s,children:u,placeholder:p,readOnly:h,width:g,style:v})=>{const m=()=>{x((e=>Object.assign(Object.assign({},e),{version:e.version+1})))},y=d((()=>r?[Ac,...r]:[Ac]),[r]),b=d((()=>i.map((e=>e.getPlugin))),[i]),[w,x]=f((()=>{n.id||(n.id=t||G()),n.applyChanges=m,n.readOnly=h||!1,y&&(n.formats=jc(n,y)),n.blocks=function(e,t){const n={};return t.forEach((t=>{var o;const r=ii(t.elements),i=null===(o=null==r?void 0:r.props)||void 0===o?void 0:o.nodeType;if("inline"!==i&&"inlineVoid"!==i){const o={};Object.keys(t.elements).forEach((e=>{const n=fi(t.elements[e],["render"]);o[e]=n}));const{display:r,placeholder:i,shortcuts:l}=t.options||{};n[t.type]={type:t.type,elements:o,hasCustomEditor:!!t.customEditor,options:{display:r,placeholder:i,shortcuts:l},isActive:()=>{const n=P(e,{at:e.selection});return(null==n?void 0:n.type)===t.type},toggle:n=>bc(e,t.type,n),create:n=>xc(e,t.type,n),update:(t,n)=>{mc(e,t,n)},delete:t=>{cc(e,t)}}}})),n}(n,b);const e=function(e){return!!e&&"object"==typeof e&&0!==Object.keys(e).length}(o);return e||void 0===o||console.error(`Initial value is not valid. Should be an object with blocks. You passed: ${JSON.stringify(o)}`),n.children=e?o:_c,n.blockEditorsMap=Bc(n),n.shortcuts=function(e){const t={};return Object.values(e.blocks).forEach((e=>{var n,o,r,i;e.options&&Array.isArray(null===(n=e.options)||void 0===n?void 0:n.shortcuts)&&(null===(o=e.options)||void 0===o?void 0:o.shortcuts.length)>0&&(null===(i=null===(r=e.options)||void 0===r?void 0:r.shortcuts)||void 0===i||i.forEach((n=>{t[n]=e})))})),t}(n),n.plugins=function(e){const t={},n={};return e.forEach((e=>{e.elements&&Object.keys(e.elements).forEach((t=>{var o;const r=e.elements[t],i=null===(o=r.props)||void 0===o?void 0:o.nodeType;"inline"!==i&&"inlineVoid"!==i||(n[t]=Object.assign(Object.assign({},r),{rootPlugin:e.type}))})),t[e.type]=e})),e.forEach((e=>{if(e.elements){const o=Object.assign(Object.assign({},e.elements),n);t[e.type]=Object.assign(Object.assign({},e),{elements:o})}})),t}(b),n.commands=function(e,t){const n={};return t.forEach((t=>{t.commands&&Object.keys(t.commands).forEach((o=>{var r;(null===(r=t.commands)||void 0===r?void 0:r[o])&&(n[o]=(...n)=>{var r;return null===(r=t.commands)||void 0===r?void 0:r[o](e,...n)})}))})),n}(n,b),n.on=Tc,n.once=Mc,n.off=Lc,n.emit=Pc,{editor:n,version:0}}));return e(F,Object.assign({editorState:w},{children:e(si,Object.assign({tools:a},{children:e(Sc,Object.assign({placeholder:p,marks:y,autoFocus:l,className:c,selectionBoxRoot:s,width:g,style:v},{children:u}))}))}))},zc=Object.assign(Object.assign({},wi),{ExtendedBlockActions:({id:o,className:r,style:i,onClick:l,children:c})=>{const a=V(),[s,d]=f(!1),{refs:u,floatingStyles:p,context:h}=Ir({placement:"bottom-start",open:s,onOpenChange:d,middleware:[Ho(),$o(),Fo(),Eo(10)],whileElementsMounted:zo}),{isMounted:g,styles:v}=Hr(h,{duration:100}),m=Object.assign(Object.assign({},v),p);return a?null:t(n,{children:[g&&e(bi,Object.assign({isOpen:!0,onClose:()=>d(!1),refs:u,style:m},{children:c})),e("button",Object.assign({type:"button",contentEditable:!1,ref:u.setReference,id:o,className:`yoopta-button yoopta-extended-block-actions ${r||""}`,onClick:()=>{null==l||l(),d(!0)},style:s?Object.assign(Object.assign({},i),{opacity:1}):i},{children:e(Zr,{})}))]})},Portal:hi,Overlay:pi});function Fc(e,t){const n=Object.keys(e.children),{type:o}=t||{},r=n.find((t=>e.children[t].type===o));return r?e.children[r]:null}function $c(e,t){var n;const o=[];return t.forEach((t=>{if(t.nodeType===Node.TEXT_NODE&&o.push({text:t.textContent||""}),t.nodeType===Node.ELEMENT_NODE){const n=t;"P"!==n.nodeName&&"SPAN"!==n.nodeName&&"DIV"!==n.nodeName||o.push(Object.assign({},$c(e,n.childNodes)[0])),"B"!==n.nodeName&&"STRONG"!==n.nodeName||o.push(Object.assign({bold:!0},$c(e,n.childNodes)[0])),"I"!==n.nodeName&&"EM"!==n.nodeName||o.push(Object.assign({italic:!0},$c(e,n.childNodes)[0])),"S"!==n.nodeName&&"STRIKE"!==n.nodeName||o.push(Object.assign({strike:!0},$c(e,n.childNodes)[0])),"U"!==n.nodeName&&"INS"!==n.nodeName||o.push(Object.assign({underline:!0},$c(e,n.childNodes)[0])),"CODE"===n.nodeName&&o.push(Object.assign({code:!0},$c(e,n.childNodes)[0])),"A"===n.nodeName&&o.push({id:G(),type:"link",props:{url:n.getAttribute("href")||"",target:n.getAttribute("target")||"",rel:n.getAttribute("rel")||""},children:$c(e,n.childNodes)})}})),0!==o.length||(null===(n=o[0])||void 0===n?void 0:n.text)||o.push({text:""}),o}function Hc(e){return e.map((e=>{if("text"in e){let t=e.text;return e.bold&&(t=`<b>${t}</b>`),e.italic&&(t=`<i>${t}</i>`),e.strike&&(t=`<s>${t}</s>`),e.underline&&(t=`<u>${t}</u>`),e.code&&(t=`<code>${t}</code>`),t}if("link"===e.type){const{url:t,target:n,rel:o}=e.props;return`<a href="${t}" target="${n}" rel="${o}">${Hc(e.children)}</a>`}return""})).join("")}function Uc(e){return e.map((e=>{if("text"in e){let t=e.text;return e.bold&&(t=`**${t}**`),e.italic&&(t=`*${t}*`),e.strike&&(t=`~~${t}~~`),e.underline&&(t=`<u>${t}</u>`),e.code&&(t=`\`${t}\``),t}if("link"===e.type){const{url:t,target:n,rel:o}=e.props;return`[${Uc(e.children)}](${t})`}return""})).join("")}function Vc(e){return Array.from(new Set(e))}function Kc(e,t){try{w.blur(t),w.deselect(t),D.deselect(t)}catch(e){}e.setBlockSelected(null),e.setSelection(null)}const Wc={underline:{type:"underline",tag:"U"},strike:{type:"strike",tag:"S"},code:{type:"code",tag:"CODE"},italic:{type:"italic",tag:"I"},bold:{type:"bold",tag:"B"}};function Yc(e,t){return e.map((e=>{var n,o;let r="";if(e.text)return r=Object.keys(Wc).reduce(((t,n)=>e[n]?`<${Wc[n].tag}>${t}</${Wc[n].tag}>`:t),e.text),r;if(e.type){const i=function(e,t){return Object.values(e).find((e=>{var n,o;return e.type===(null===(o=null===(n=e.elements)||void 0===n?void 0:n[t])||void 0===o?void 0:o.rootPlugin)}))}(t,e.type);if(i&&(null===(o=null===(n=i.parsers)||void 0===n?void 0:n.html)||void 0===o?void 0:o.serialize))return r=i.parsers.html.serialize(e,Yc(e.children,t)),r}return r})).join("")}function Xc(e,t){const n=Object.values(t).filter((t=>{var n;return!(Array.isArray(e.selectedBlocks)&&e.selectedBlocks.length>0)||(null===(n=e.selectedBlocks)||void 0===n?void 0:n.includes(t.meta.order))})).sort(((e,t)=>e.meta.order-t.meta.order)).map((t=>{var n,o;const r=e.plugins[t.type];if(r&&(null===(o=null===(n=r.parsers)||void 0===n?void 0:n.html)||void 0===o?void 0:o.serialize)){const n=Yc(t.value[0].children,e.plugins);return r.parsers.html.serialize(t.value[0],n,t.meta)}return""}));return`<body id="yoopta-clipboard" data-editor-id="${e.id}">${n.join("")}</body>`}function qc(){const e={id:"",children:{},selection:null,selectedBlocks:null,readOnly:!1,isEmpty:()=>function(e){const t=Object.values(e.children);if(t.length>1)return!1;const n=t[0];if(!n)return!0;if("Paragraph"!==n.type)return!1;const o=Ln(e,{at:[n.meta.order]});if(!o)return!0;try{return!(S.string(o,[0]).length>0)}catch(e){return!0}}(e),getEditorValue:()=>function(e){return e.applyChanges(),e.children}(e),setEditorValue:(...t)=>function(e,t){e.children=t,e.blockEditorsMap=Bc(e),e.applyChanges(),e.emit("change",e.children)}(e,...t),applyChanges:()=>{},insertBlock:(...t)=>lc(e,...t),insertBlocks:(...t)=>wc(e,...t),deleteBlocks:(...t)=>ac(e,...t),deleteBlock:(...t)=>cc(e,...t),duplicateBlock:(...t)=>vc(e,...t),toggleBlock:(...t)=>bc(e,...t),increaseBlockDepth:(...t)=>fc(e,...t),decreaseBlockDepth:(...t)=>pc(e,...t),moveBlock:(...t)=>sc(e,...t),focusBlock:(...t)=>dc(e,...t),getBlock:(...t)=>kc(e,...t),updateBlock:(...t)=>mc(e,...t),splitBlock:(...t)=>uc(e,...t),setSelection:(...t)=>function(e,t,n={}){const{applyChanges:o=!0}=n;e.selection=t,o&&e.applyChanges()}(e,...t),setBlockSelected:(...t)=>function(e,t,n={}){const{only:o=!1,allSelected:r=!1}=n,i=e.selectedBlocks||[];if(null===t)e.selectedBlocks=null;else if(t.length>1)e.selectedBlocks=t;else if(o)e.selectedBlocks=t;else if(r){const t=Object.keys(e.children).map(((e,t)=>t));e.selectedBlocks=Vc(t)}else e.selectedBlocks=Vc(i.concat(t));e.applyChanges()}(e,...t),blockEditorsMap:{},blocks:{},formats:{},shortcuts:{},plugins:{},commands:{},on:(e,t)=>{},off:(e,t)=>{},emit:(e,...t)=>{},once:(e,t)=>{},isFocused:()=>function(e){return!!Hi.get(e)}(e),focus:()=>function(e){if(e.readOnly)return;const t=P(e,{at:[0]});t&&(Hi.set(e,!0),e.focusBlock(t.id,{waitExecution:!0}),e.emit("focus",!0))}(e),blur:(...t)=>function(e,t={}){var n;const o=null!==(n=t.slate)&&void 0!==n?n:Ln(e);if(!o)return;const{waitExecution:r,waitExecutionMs:i}=t;r?setTimeout((()=>Kc(e,o)),i):(Hi.set(e,!1),Kc(e,o),e.emit("blur",!1),e.applyChanges())}(e,...t),getHTML:t=>Xc(e,t),getMarkdown:t=>function(e,t){return function(e,t){return t.sort(((e,t)=>e.meta.order>t.meta.order?1:-1)).map((t=>{var n,o;const r=e.plugins[t.type];if(r){const e=t.value[0];if(null===(o=null===(n=r.parsers)||void 0===n?void 0:n.markdown)||void 0===o?void 0:o.serialize){const t=r.parsers.markdown.serialize(e,e.children.map((e=>e.text)).join(""));if(t)return t}}return""})).join("\n")}(e,Object.values(t))}(e,t),getPlainText:t=>function(e,t){const n=Xc(e,t),o=document.createElement("div");return o.innerHTML=n,o.innerText}(e,t),refElement:null};return e}function Zc(e,t,n){const o=e.children[t];if(!o)throw new Error(`Block with id ${t} not found`);const r=Ln(e,{at:[o.meta.order]});if(!r)return void console.warn("No slate found");let i=e=>A.isElement(e);(null==n?void 0:n.type)&&(i=e=>A.isElement(e)&&e.type===(null==n?void 0:n.type));try{const[e]=S.nodes(r,{at:(null==n?void 0:n.path)||r.selection||[0],match:i,mode:"lowest"});return e}catch(e){}}function Gc(e,t,n){const o=Zc(e,t,n);if(o)return o[0]}const Jc={createElement:function(e,t,n,o){const r=e.children[t];if(!r)throw new Error(`Block with id ${t} not found`);const i=Ln(e,{at:[r.meta.order]});i?S.withoutNormalizing(i,(()=>{const l=e.blocks[r.type],c=l.elements[n.type],a=J({type:n.type,props:Object.assign(Object.assign({},c.props),n.props)}),s=Object.keys(l.elements);let d=[];s.forEach((e=>{const t=l.elements[e];e===n.type&&Array.isArray(t.children)&&t.children.length>0&&t.children.forEach((e=>{const t=l.elements[e];d.push(J({type:e,props:t.props}))}))})),d.length>0&&(a.children=d);const{path:u,focus:f=!0}=o||{};let p;const h=Zc(e,t,{type:n.type});if(h){const[,e]=h;j.isPath(u)?p=u:"prev"===u?p=j.previous(e):"next"===u&&(p=j.next(e))}if(D.insertNodes(i,a,{at:p,select:f}),f&&d.length>0){const n=d[0],o=Zc(e,t,{path:p,type:n.type});if(o){const[,e]=o;D.select(i,e)}}e.applyChanges(),e.emit("change",e.children)})):console.warn("No slate found")},deleteElement:function(e,t,n){const o=e.children[t];if(!o)throw new Error(`Block with id ${t} not found`);const r=Ln(e,{at:[o.meta.order]});r?S.withoutNormalizing(r,(()=>{D.removeNodes(r,{at:n.path,match:e=>A.isElement(e)&&e.type===n.type}),e.applyChanges(),e.emit("change",e.children)})):console.warn("No slate found")},updateElement:function(e,t,n,o){const r=e.children[t];if(!r)throw new Error(`Block with id ${t} not found`);const i=Ln(e,{at:[r.meta.order]});i?S.withoutNormalizing(i,(()=>{const[t]=S.nodes(i,{at:(null==o?void 0:o.path)||[0],match:e=>A.isElement(e)&&e.type===n.type}),r=null==t?void 0:t[0],l=null==t?void 0:t[1],c=(null==r?void 0:r.props)||{},a={props:Object.assign(Object.assign({},c),n.props)};D.setNodes(i,a,{at:(null==o?void 0:o.path)||l||[0],match:e=>A.isElement(e)&&e.type===n.type,mode:"lowest"}),e.applyChanges(),e.emit("change",e.children)})):console.warn("No slate found")},insertElementText:function(e,t,n){const{blockId:o,focus:r}=n||{},i=o?e.children[o]:P(e);if(!i)return void console.warn(`To set text programmatically, you must provide a valid blockId. Got: ${o}`);const l=Ln(e,{at:[i.meta.order]});if(!l)return void console.warn("No slate found");const c=e.blocks[i.type],a=Array.from({length:Object.keys(c.elements).length},(e=>0));let s=l.selection||a;s?S.withoutNormalizing(l,(()=>{B.isRange(s)&&!B.isCollapsed(s)&&D.collapse(l,{edge:"end"}),D.insertText(l,t,{at:s}),e.applyChanges(),e.emit("change",e.children),r&&e.focusBlock(i.id,{waitExecution:!0,shouldUpdateBlockSelection:!0})})):console.warn("No valid path or selection found for text insertion")},getElement:Gc,getElementChildren:function(e,t,n){const o=Gc(e,t,n);if(o)return o.children},getElementEntry:Zc,isElementEmpty:function(e,t,n){const o=e.children[t];if(!o)throw new Error(`Block with id ${t} not found`);const r=Ln(e,{at:[o.meta.order]});if(!r)return void console.warn("No slate found");const[i]=S.nodes(r,{at:n.path||r.selection,match:e=>A.isElement(e)&&e.type===n.type});if(i){const[e,t]=i;return 0===S.string(r,t).trim().length}return!1},getElementPath:function(e,t,n){const o=e.children[t];if(!o)throw new Error(`Block with id ${t} not found`);const r=Ln(e,{at:[o.meta.order]});if(r)try{return w.findPath(r,n)}catch(e){}else console.warn("No slate found")},getParentElementPath:function(e,t,n){const o=e.children[t];if(!o)throw new Error(`Block with id ${t} not found`);const r=Ln(e,{at:[o.meta.order]});if(!r)return console.warn("No slate found"),[];try{const e=w.findPath(r,n);return j.parent(e)}catch(e){}}};!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&o.firstChild?o.insertBefore(r,o.firstChild):o.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}(".yoo-editor-z-\\[100\\]{z-index:100}.yoo-editor-mr-2{margin-right:.5rem}.yoo-editor-h-4{height:1rem}.yoo-editor-w-4{width:1rem}.yoopta-editor *{border:0 solid #e5e7eb;box-sizing:border-box;scrollbar-color:#d3d1cb transparent}::-moz-selection{background:#c6ddf8}::selection{background:#c6ddf8}.yoopta-placeholder:after{color:inherit;content:attr(data-placeholder);font-size:75%;font-style:inherit;font-weight:inherit;opacity:.5;padding-left:5px;position:absolute;text-indent:2px;top:50%;transform:translateY(-50%);-webkit-user-select:none;-moz-user-select:none;user-select:none}.yoopta-button{background-color:transparent;border-style:none;cursor:pointer}.yoopta-block{border-radius:.25rem;margin-bottom:1px;margin-top:2px;padding:0 2px;position:relative}.yoopta-selection-block{background-color:#2383e224;border-radius:.25rem;height:100%;left:0;opacity:1;pointer-events:none;position:absolute;top:0;width:100%;z-index:90}.yoopta-block-actions{display:flex;left:-50px;opacity:0;position:absolute;top:2px;transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.yoopta-block-actions[data-hovered-state-open=true]{opacity:1}.yoopta-block-actions-plus{align-items:center;background-color:inherit;background-color:transparent;border-radius:6px;border-style:none;color:#37352f59;cursor:pointer;display:flex;height:24px;justify-content:center;margin:0 1px;padding:0;position:relative;transition-duration:.18s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);width:24px}.yoopta-block-actions-plus:active,.yoopta-block-actions-plus:focus,.yoopta-block-actions-plus:hover{background-color:#37362f14}.yoopta-block-actions-drag{align-items:center;background-color:inherit;background-color:transparent;border-radius:6px;border-style:none;color:#37352f59;cursor:pointer;display:flex;height:24px;justify-content:center;margin:0 1px;padding:0;position:relative;transition-duration:.18s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);width:18px}.yoopta-block-actions-drag:active,.yoopta-block-actions-drag:focus,.yoopta-block-actions-drag:hover{background-color:#37362f14}.yoopta-slate:focus{outline:2px solid transparent;outline-offset:2px}.yoopta-slate:focus-visible{outline:2px solid transparent;outline-offset:2px}.yoopta-block-options-button{background-color:transparent;border-radius:.125rem;border-style:none;cursor:pointer;display:flex;justify-content:flex-start;line-height:120%;margin-left:4px;margin-right:4px;padding:.375rem .5rem;width:100%}.yoopta-block-options-button:hover{background-color:#37352f14}.yoopta-block-options-item{align-items:center;cursor:default;display:flex;font-size:.875rem;line-height:1.25rem;outline:2px solid transparent;outline-offset:2px;position:relative;transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);-webkit-user-select:none;-moz-user-select:none;user-select:none}.yoopta-block-options-item[data-disabled]{opacity:.5;pointer-events:none}.yoopta-extended-block-actions{--tw-bg-opacity:1;align-items:center;background-color:rgb(238 238 238/var(--tw-bg-opacity));border-radius:2px;border-style:none;cursor:pointer;display:flex;height:22px;justify-content:space-between;opacity:1;padding:0 4px;position:absolute;right:8px;top:8px;transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-timing-function:cubic-bezier(.4,0,1,1);width:22px;z-index:10}.yoopta-block-options-separator{background-color:#37352f14;height:1px;margin-bottom:4px;margin-top:4px;width:100%}.yoopta-block-options-menu-content{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);background-color:rgb(255 255 255/var(--tw-bg-opacity));border-color:rgb(229 231 235/var(--tw-border-opacity));border-radius:.375rem;border-style:solid;border-width:1px;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);min-width:200px;overflow:hidden;padding:6px 0;position:relative;width:auto}.yoopta-block-options-group{display:flex;flex-direction:column}.yoopta-align-left{justify-content:flex-start;text-align:left}.yoopta-align-center{justify-content:center;text-align:center}.yoopta-align-right{justify-content:flex-end;text-align:right}");export{Ec as Blocks,Jc as Elements,zi as HOTKEYS,zc as UI,L as YooptaPlugin,Q as buildBlockData,J as buildBlockElement,ci as buildBlockElementsStructure,qc as createYooptaEditor,Rc as createYooptaMark,Ic as default,$c as deserializeTextNodes,P as findPluginBlockBySelectionPath,Fc as findPluginBlockByType,Ln as findSlateBySelectionPath,G as generateId,ii as getRootBlockElement,ri as getRootBlockElementType,Hc as serializeTextNodes,Uc as serializeTextNodesIntoMarkdown,H as useBlockData,W as useBlockSelected,$ as useYooptaEditor,U as useYooptaFocused,K as useYooptaPluginOptions,V as useYooptaReadOnly,di as useYooptaTools};
13
+ function Zl(e){return"[object Object]"===Object.prototype.toString.call(e)}var Gl={isHistory(e){return!1!==Zl(t=e)&&(void 0===(n=t.constructor)||!1!==Zl(o=n.prototype)&&!1!==o.hasOwnProperty("isPrototypeOf"))&&Array.isArray(e.redos)&&Array.isArray(e.undos)&&(0===e.redos.length||_.isOperationList(e.redos[0].operations))&&(0===e.undos.length||_.isOperationList(e.undos[0].operations));var t,n,o}},Jl=new WeakMap,Ql=new WeakMap,ec={isHistoryEditor:e=>Gl.isHistory(e.history)&&S.isEditor(e),isMerging:e=>Ql.get(e),isSaving:e=>Jl.get(e),redo(e){e.redo()},undo(e){e.undo()},withoutMerging(e,t){var n=ec.isMerging(e);Ql.set(e,!1),t(),Ql.set(e,n)},withoutSaving(e,t){var n=ec.isSaving(e);Jl.set(e,!1),t(),Jl.set(e,n)}},tc=e=>{var t=e,{apply:n}=t;return t.history={undos:[],redos:[]},t.redo=()=>{var{history:e}=t,{redos:n}=e;if(n.length>0){var o=n[n.length-1];o.selectionBefore&&D.setSelection(t,o.selectionBefore),ec.withoutSaving(t,(()=>{S.withoutNormalizing(t,(()=>{for(var e of o.operations)t.apply(e)}))})),e.redos.pop(),t.writeHistory("undos",o)}},t.undo=()=>{var{history:e}=t,{undos:n}=e;if(n.length>0){var o=n[n.length-1];ec.withoutSaving(t,(()=>{S.withoutNormalizing(t,(()=>{var e=o.operations.map(_.inverse).reverse();for(var n of e)t.apply(n);o.selectionBefore&&D.setSelection(t,o.selectionBefore)}))})),t.writeHistory("redos",o),e.undos.pop()}},t.apply=e=>{var{operations:o,history:r}=t,{undos:i}=r,l=i[i.length-1],c=l&&l.operations[l.operations.length-1],a=ec.isSaving(t),s=ec.isMerging(t);if(null==a&&(a=oc(e)),a){if(null==s&&(s=null!=l&&(0!==o.length||nc(e,c))),l&&s)l.operations.push(e);else{var d={operations:[e],selectionBefore:t.selection};t.writeHistory("undos",d)}for(;i.length>100;)i.shift();r.redos=[]}n(e)},t.writeHistory=(e,n)=>{t.history[e].push(n)},t},nc=(e,t)=>!(!t||"insert_text"!==e.type||"insert_text"!==t.type||e.offset!==t.offset+t.text.length||!j.equals(e.path,t.path))||!(!t||"remove_text"!==e.type||"remove_text"!==t.type||e.offset+e.text.length!==t.offset||!j.equals(e.path,t.path)),oc=(e,t)=>"set_selection"!==e.type;const rc=(e,t)=>{const{insertText:n}=t;return t.insertText=o=>{var r;const{selection:i}=t;if(" "===o&&i&&B.isCollapsed(i)){const{anchor:l}=i,c=S.above(t,{match:e=>A.isElement(e)&&S.isBlock(t,e),mode:"lowest"});if(!c)return;const[,a]=c,s=S.parent(t,a),[d]=s;if(A.isElement(d)&&!R.isText(d.children[0]))return n(o);const u=c?a:[],f={anchor:l,focus:S.start(t,u)},p=S.string(t,f),h=null===(r=e.shortcuts)||void 0===r?void 0:r[p];if(!!h&&!h.isActive())return D.select(t,f),D.delete(t),e.blocks[h.type].toggle({focus:!0}),void Ec.createBlock(e,h.type,{deleteText:!1,focus:!0})}n(o)},t};function ic(e){return rc(e,tc(C(T())))}function lc(e,t,n={}){e.children=Xl(e.children);const{at:o=null,focus:r=!1,slate:i=null}=n,l=P(e),c=e.plugins[t.type].events||{},{onCreate:a}=c,s=o,d={id:G(),value:t.value,type:t.type,meta:Object.assign(Object.assign({},t.meta),{order:0})};let u=!1;if(i&&i.selection){const e=S.string(i,i.selection.anchor.path);u=S.isStart(i,i.selection.anchor,i.selection.anchor.path)&&e.length>0}if(s){const[t]=s;Object.values(e.children).forEach((e=>{e.meta.order>=t&&(e.meta.order+=1)})),d.meta.order=t}else{const t=Object.keys(e.children).length;d.meta.order=t}const f=ic(e);e.blockEditorsMap[d.id]=f,u&&l&&(d.meta.order=l.meta.order,l.meta.order+=1),e.children[d.id]=d;const p=null==l?void 0:l.id;e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),null==a||a(e,d.id),r&&e.focusBlock(u&&p?p:d.id)}function cc(e,t={}){const{at:n=e.selection,deleteAll:o=!1,fromPaths:r,focus:i}=t;if(Array.isArray(r)&&r.length>0){e.children=Xl(e.children),r.forEach((t=>{const n=P(e,{at:[t]});if(n){const t=e.plugins[n.type].events||{},{onDestroy:o}=t;null==o||o(e,n.id),delete e.children[n.id],delete e.blockEditorsMap[n.id]}}));return Object.keys(e.children).forEach(((t,n)=>{e.children[t].meta.order=n})),e.children=ql(e.children),e.applyChanges(),void e.emit("change",e.children)}if(o||1===Object.keys(e.children).length){e.children={},e.blockEditorsMap={};const t=Q({id:G()}),n=ic(e);return e.children[t.id]=t,e.blockEditorsMap[t.id]=n,e.setSelection([0]),e.setBlockSelected(null),e.focusBlock(t.id,{slate:n,waitExecution:!0}),e.applyChanges(),void e.emit("change",e.children)}if(!n)return;e.children=Xl(e.children);const[l]=n,c=Object.keys(e.children),a=c.find((t=>e.children[t].meta.order===l));if(c.forEach((t=>{const n=e.children[t];n.meta.order>l&&(n.meta.order-=1)})),a){const t=e.children[a],n=e.plugins[t.type].events||{},{onDestroy:o}=n;null==o||o(e,a),delete e.children[a],delete e.blockEditorsMap[a]}if(e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),i){const n=e.selection?e.selection[0]-1:0,o=P(e,{at:[n]});o&&e.focusBlock(o.id,{focusAt:t.focusAt})}}function ac(e,t={}){const{deleteAll:n=!1,paths:o,blockIds:r,focus:i=!0}=t;if(n||1===Object.keys(e.children).length){e.children={},e.blockEditorsMap={};const t=Q({id:G()}),n=ic(e);return e.children[t.id]=t,e.blockEditorsMap[t.id]=n,e.setSelection([0]),e.applyChanges(),e.emit("change",e.children),void(i&&e.focusBlock(t.id,{waitExecution:!0}))}if(Array.isArray(r)&&r.length>0){e.children=Xl(e.children),r.forEach((t=>{delete e.children[t],delete e.blockEditorsMap[t]}));const t=Object.keys(e.children).sort(((t,n)=>e.children[t].meta.order>e.children[n].meta.order?1:-1));return t.forEach(((t,n)=>{e.children[t].meta.order=n})),e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),void(i&&e.focusBlock(t[0],{waitExecution:!0}))}if(Array.isArray(o)&&o.length>0){e.children=Xl(e.children),o.forEach((t=>{const n=P(e,{at:[t]});n&&(delete e.children[n.id],delete e.blockEditorsMap[n.id])}));const t=Object.keys(e.children).sort(((t,n)=>e.children[t].meta.order>e.children[n].meta.order?1:-1));return t.forEach(((t,n)=>{e.children[t].meta.order=n})),e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),void(i&&e.focusBlock(t[0],{waitExecution:!0}))}}function sc(e,t,n){e.children=Xl(e.children);const[o]=n,r=e.children[t],i=Object.values(e.children).find((e=>e.meta.order===o)),l=r.meta.order<i.meta.order,c=r.meta.order>i.meta.order;Object.values(e.children).forEach((e=>{l?e.meta.order>r.meta.order&&e.meta.order<=i.meta.order&&e.meta.order--:c&&e.meta.order<r.meta.order&&e.meta.order>=i.meta.order&&e.meta.order++})),r.meta.order=o,r.meta.depth=i.meta.depth,e.setSelection([o]),e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children)}function dc(e,t,n={}){try{const{focusAt:o,waitExecution:r=!0,waitExecutionMs:i=0,shouldUpdateBlockSelection:l=!0}=n,c=()=>{const r=n.slate||e.blockEditorsMap[t],i=e.children[t];if(!r||!i)return;if(!e.blocks[i.type].hasCustomEditor){const e=function(e,t){if(M.isPoint(t))return t;if(j.isPath(t))return{path:t,offset:0};const[,n]=S.first(e,[0]);return{path:n||[0,0],offset:0}}(r,o);D.select(r,e),w.focus(r)}l&&setTimeout((()=>{e.setSelection([i.meta.order])}),0)};r?setTimeout((()=>c()),i):c(),Hi.set(e,!0)}catch(e){}}function uc(e,t={}){const{slate:n,focus:o=!0}=t,r=P(e);n&&n.selection&&r&&S.withoutNormalizing(n,(()=>{e.children=Xl(e.children);const t=j.parent(n.selection.anchor.path);D.splitNodes(n,{at:n.selection,match:e=>A.isElement(e),always:!0,mode:"highest"});const i=t[0]+1,l=n.children.slice()[i];D.removeNodes(n,{at:[i],match:e=>A.isElement(e),mode:"highest"});const c={id:G(),type:r.type,meta:{order:r.meta.order+1,depth:r.meta.depth,align:r.meta.align},value:[l]};Object.values(e.children).forEach((e=>{e.meta.order>=c.meta.order&&(e.meta.order+=1)}));const a=ic(e);e.blockEditorsMap[c.id]=a,e.children[c.id]=c,e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),o&&e.focusBlock(c.id,{slate:a})}))}function fc(e,t={}){const{at:n=e.selection,blockId:o=""}=t;if(!o&&!n)return;e.children=Xl(e.children);const r=e.children[o]||P(e);r&&(r.meta.depth=r.meta.depth+1,e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children))}function pc(e,t={}){const{at:n=e.selection,blockId:o=""}=t;if(!o&&!n)return;e.children=Xl(e.children);const r=e.children[o]||P(e);r&&(r.meta.depth=0===r.meta.depth?0:r.meta.depth-1,e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children))}var hc={};!function(e,t){var n="__lodash_hash_undefined__",o=9007199254740991,r="[object Arguments]",i="[object Boolean]",l="[object Date]",c="[object Function]",a="[object GeneratorFunction]",s="[object Map]",d="[object Number]",u="[object Object]",f="[object Promise]",p="[object RegExp]",h="[object Set]",g="[object String]",v="[object Symbol]",m="[object WeakMap]",y="[object ArrayBuffer]",b="[object DataView]",w="[object Float32Array]",x="[object Float64Array]",k="[object Int8Array]",E="[object Int16Array]",O="[object Int32Array]",C="[object Uint8Array]",S="[object Uint8ClampedArray]",D="[object Uint16Array]",j="[object Uint32Array]",B=/\w*$/,R=/^\[object .+?Constructor\]$/,A=/^(?:0|[1-9]\d*)$/,_={};_[r]=_["[object Array]"]=_[y]=_[b]=_[i]=_[l]=_[w]=_[x]=_[k]=_[E]=_[O]=_[s]=_[d]=_[u]=_[p]=_[h]=_[g]=_[v]=_[C]=_[S]=_[D]=_[j]=!0,_["[object Error]"]=_[c]=_[m]=!1;var N="object"==typeof Y&&Y&&Y.Object===Object&&Y,T="object"==typeof self&&self&&self.Object===Object&&self,M=N||T||Function("return this")(),L=t&&!t.nodeType&&t,P=L&&e&&!e.nodeType&&e,I=P&&P.exports===L;function z(e,t){return e.set(t[0],t[1]),e}function F(e,t){return e.add(t),e}function $(e,t,n,o){var r=-1,i=e?e.length:0;for(o&&i&&(n=e[++r]);++r<i;)n=t(n,e[r],r,e);return n}function H(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function U(e){var t=-1,n=Array(e.size);return e.forEach((function(e,o){n[++t]=[o,e]})),n}function V(e,t){return function(n){return e(t(n))}}function K(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var W,X=Array.prototype,q=Function.prototype,Z=Object.prototype,G=M["__core-js_shared__"],J=(W=/[^.]+$/.exec(G&&G.keys&&G.keys.IE_PROTO||""))?"Symbol(src)_1."+W:"",Q=q.toString,ee=Z.hasOwnProperty,te=Z.toString,ne=RegExp("^"+Q.call(ee).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),oe=I?M.Buffer:void 0,re=M.Symbol,ie=M.Uint8Array,le=V(Object.getPrototypeOf,Object),ce=Object.create,ae=Z.propertyIsEnumerable,se=X.splice,de=Object.getOwnPropertySymbols,ue=oe?oe.isBuffer:void 0,fe=V(Object.keys,Object),pe=Ie(M,"DataView"),he=Ie(M,"Map"),ge=Ie(M,"Promise"),ve=Ie(M,"Set"),me=Ie(M,"WeakMap"),ye=Ie(Object,"create"),be=Ue(pe),we=Ue(he),xe=Ue(ge),ke=Ue(ve),Ee=Ue(me),Oe=re?re.prototype:void 0,Ce=Oe?Oe.valueOf:void 0;function Se(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function De(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function je(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function Be(e){this.__data__=new De(e)}function Re(e,t){var n=Ke(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&We(e)}(e)&&ee.call(e,"callee")&&(!ae.call(e,"callee")||te.call(e)==r)}(e)?function(e,t){for(var n=-1,o=Array(e);++n<e;)o[n]=t(n);return o}(e.length,String):[],o=n.length,i=!!o;for(var l in e)!t&&!ee.call(e,l)||i&&("length"==l||$e(l,o))||n.push(l);return n}function Ae(e,t,n){var o=e[t];ee.call(e,t)&&Ve(o,n)&&(void 0!==n||t in e)||(e[t]=n)}function _e(e,t){for(var n=e.length;n--;)if(Ve(e[n][0],t))return n;return-1}function Ne(e,t,n,o,f,m,R){var A;if(o&&(A=m?o(e,f,m,R):o(e)),void 0!==A)return A;if(!qe(e))return e;var N=Ke(e);if(N){if(A=function(e){var t=e.length,n=e.constructor(t);t&&"string"==typeof e[0]&&ee.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!t)return function(e,t){var n=-1,o=e.length;t||(t=Array(o));for(;++n<o;)t[n]=e[n];return t}(e,A)}else{var T=Fe(e),M=T==c||T==a;if(Ye(e))return function(e,t){if(t)return e.slice();var n=new e.constructor(e.length);return e.copy(n),n}(e,t);if(T==u||T==r||M&&!m){if(H(e))return m?e:{};if(A=function(e){return"function"!=typeof e.constructor||He(e)?{}:(t=le(e),qe(t)?ce(t):{});var t}(M?{}:e),!t)return function(e,t){return Le(e,ze(e),t)}(e,function(e,t){return e&&Le(t,Ze(t),e)}(A,e))}else{if(!_[T])return m?e:{};A=function(e,t,n,o){var r=e.constructor;switch(t){case y:return Me(e);case i:case l:return new r(+e);case b:return function(e,t){var n=t?Me(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,o);case w:case x:case k:case E:case O:case C:case S:case D:case j:return function(e,t){var n=t?Me(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}(e,o);case s:return function(e,t,n){var o=t?n(U(e),!0):U(e);return $(o,z,new e.constructor)}(e,o,n);case d:case g:return new r(e);case p:return function(e){var t=new e.constructor(e.source,B.exec(e));return t.lastIndex=e.lastIndex,t}(e);case h:return function(e,t,n){var o=t?n(K(e),!0):K(e);return $(o,F,new e.constructor)}(e,o,n);case v:return c=e,Ce?Object(Ce.call(c)):{}}var c}(e,T,Ne,t)}}R||(R=new Be);var L=R.get(e);if(L)return L;if(R.set(e,A),!N)var P=n?function(e){return function(e,t,n){var o=t(e);return Ke(e)?o:function(e,t){for(var n=-1,o=t.length,r=e.length;++n<o;)e[r+n]=t[n];return e}(o,n(e))}(e,Ze,ze)}(e):Ze(e);return function(e,t){for(var n=-1,o=e?e.length:0;++n<o&&!1!==t(e[n],n,e););}(P||e,(function(r,i){P&&(r=e[i=r]),Ae(A,i,Ne(r,t,n,o,i,e,R))})),A}function Te(e){return!(!qe(e)||(t=e,J&&J in t))&&(Xe(e)||H(e)?ne:R).test(Ue(e));var t}function Me(e){var t=new e.constructor(e.byteLength);return new ie(t).set(new ie(e)),t}function Le(e,t,n,o){n||(n={});for(var r=-1,i=t.length;++r<i;){var l=t[r],c=o?o(n[l],e[l],l,n,e):void 0;Ae(n,l,void 0===c?e[l]:c)}return n}function Pe(e,t){var n,o,r=e.__data__;return("string"==(o=typeof(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?r["string"==typeof t?"string":"hash"]:r.map}function Ie(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Te(n)?n:void 0}Se.prototype.clear=function(){this.__data__=ye?ye(null):{}},Se.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Se.prototype.get=function(e){var t=this.__data__;if(ye){var o=t[e];return o===n?void 0:o}return ee.call(t,e)?t[e]:void 0},Se.prototype.has=function(e){var t=this.__data__;return ye?void 0!==t[e]:ee.call(t,e)},Se.prototype.set=function(e,t){return this.__data__[e]=ye&&void 0===t?n:t,this},De.prototype.clear=function(){this.__data__=[]},De.prototype.delete=function(e){var t=this.__data__,n=_e(t,e);return!(n<0)&&(n==t.length-1?t.pop():se.call(t,n,1),!0)},De.prototype.get=function(e){var t=this.__data__,n=_e(t,e);return n<0?void 0:t[n][1]},De.prototype.has=function(e){return _e(this.__data__,e)>-1},De.prototype.set=function(e,t){var n=this.__data__,o=_e(n,e);return o<0?n.push([e,t]):n[o][1]=t,this},je.prototype.clear=function(){this.__data__={hash:new Se,map:new(he||De),string:new Se}},je.prototype.delete=function(e){return Pe(this,e).delete(e)},je.prototype.get=function(e){return Pe(this,e).get(e)},je.prototype.has=function(e){return Pe(this,e).has(e)},je.prototype.set=function(e,t){return Pe(this,e).set(e,t),this},Be.prototype.clear=function(){this.__data__=new De},Be.prototype.delete=function(e){return this.__data__.delete(e)},Be.prototype.get=function(e){return this.__data__.get(e)},Be.prototype.has=function(e){return this.__data__.has(e)},Be.prototype.set=function(e,t){var n=this.__data__;if(n instanceof De){var o=n.__data__;if(!he||o.length<199)return o.push([e,t]),this;n=this.__data__=new je(o)}return n.set(e,t),this};var ze=de?V(de,Object):function(){return[]},Fe=function(e){return te.call(e)};function $e(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||A.test(e))&&e>-1&&e%1==0&&e<t}function He(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Z)}function Ue(e){if(null!=e){try{return Q.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ve(e,t){return e===t||e!=e&&t!=t}(pe&&Fe(new pe(new ArrayBuffer(1)))!=b||he&&Fe(new he)!=s||ge&&Fe(ge.resolve())!=f||ve&&Fe(new ve)!=h||me&&Fe(new me)!=m)&&(Fe=function(e){var t=te.call(e),n=t==u?e.constructor:void 0,o=n?Ue(n):void 0;if(o)switch(o){case be:return b;case we:return s;case xe:return f;case ke:return h;case Ee:return m}return t});var Ke=Array.isArray;function We(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=o}(e.length)&&!Xe(e)}var Ye=ue||function(){return!1};function Xe(e){var t=qe(e)?te.call(e):"";return t==c||t==a}function qe(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ze(e){return We(e)?Re(e):function(e){if(!He(e))return fe(e);var t=[];for(var n in Object(e))ee.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return Ne(e,!0,!0)}}({get exports(){return hc},set exports(e){hc=e}},hc);var gc=hc;function vc(e,t={}){const{blockId:n,focus:o}=t;if(!n&&!t.at)throw new Error("blockId or path should be provided");let r=null;if(n&&(r=e.children[n],!r))throw new Error(`Block not with blockId: ${n} found`);if(t.at&&(r=P(e,{at:t.at}),!r))throw new Error(`Block in path ${t.at} not found`);if(!r)throw new Error("Block not found");e.children=Xl(e.children);Object.values(e.children).forEach((e=>{e.meta.order>r.meta.order&&(e.meta.order+=1)}));const i=(l=r,"function"==typeof window.structuredClone?window.structuredClone(l):gc(l));var l;const c=ic(e);i.id=G(),i.meta.order=r.meta.order+1,e.children[i.id]=i,e.blockEditorsMap[i.id]=c;const a=i.id;e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),o&&e.focusBlock(a,{waitExecution:!0})}function mc(e,t,n){e.children=Xl(e.children);let o=!1;const r=e.children[t];r&&(n.id&&(r.id=n.id,o=!0),n.type&&(r.type=n.type,o=!0),n.meta&&(r.meta=n.meta,o=!0),n.value&&(r.value=n.value),e.children=ql(e.children),o&&e.applyChanges(),e.emit("change",e.children))}const yc="Paragraph";function bc(e,t,n){e.children=Xl(e.children);const o=P(e,{at:(null==n?void 0:n.at)||e.selection});if(!o)throw new Error("Block from not found at current selection");let r=t;o.type===r&&(r=yc);const i=Ln(e,{at:[o.meta.order]});if(!i)throw new Error(`Slate not found for block in position ${o.meta.order}`);const l=ri(e.blocks[r].elements);S.withoutNormalizing(i,(()=>{D.setNodes(i,{type:l},{at:i.selection||[0],mode:"lowest",match:e=>A.isElement(e)&&!S.isInline(i,e)}),(null==n?void 0:n.deleteText)&&D.delete(i,{at:[0,0]});const t={id:G(),type:r,meta:Object.assign(Object.assign({},o.meta),{order:o.meta.order}),value:i.children},c=ic(e);c.children=i.children,delete e.children[o.id],delete e.blockEditorsMap[o.id],e.blockEditorsMap[t.id]=c,e.children[t.id]=t,t.value=c.children,e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),(null==n?void 0:n.focus)&&e.focusBlock(t.id,{slate:c})}))}function wc(e,t,n={}){e.children=Xl(e.children);const{at:o,focus:r}=n;let i=o||[0];const l=P(e),c=Ln(e);let a=!1,s=!1;if(c&&c.selection){const t=j.parent(c.selection.anchor.path),n=S.string(c,t).trim(),o=S.isStart(c,c.selection.anchor,t);a=""===n&&o,s=!o||n.length>0,w.blur(c),e.setSelection(null)}s&&(i=[i[0]+1]),Object.values(e.children).forEach((e=>{e.meta.order>=i[0]&&(e.meta.order+=t.length)}));const d=[];if(t.forEach(((t,n)=>{const o={id:t.id,value:t.value,type:t.type,meta:Object.assign(Object.assign({},t.meta),{order:i[0]+n})};d.push(o.meta.order),e.children[o.id]=o;const r=ic(e);e.blockEditorsMap[o.id]=r})),l&&a){const t=l.meta.order;delete e.children[l.id],delete e.blockEditorsMap[l.id],Object.keys(e.children).forEach((n=>{const o=e.children[n];o.meta.order>t&&(o.meta.order-=1)}))}e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),r&&e.setBlockSelected(d)}function xc(e,t,n){e.children=Xl(e.children);const o=P(e);if(!o)throw new Error(`No fromBlock found in the current selection path. Passed path: ${e.selection}`);const r=(null==n?void 0:n.slate)||Ln(e,{at:[null==o?void 0:o.meta.order]});if(!r||!r.selection)return;const i=e.blocks[t],l=Q({id:G(),type:i.type,meta:{order:o.meta.order,depth:o.meta.depth,align:o.meta.align}}),c=e.plugins[t].events||{},{onBeforeCreate:a,onCreate:s}=c,d="function"==typeof a?a(e,l.id):ci(e,t);(null==n?void 0:n.deleteText)&&D.delete(r,{at:[0,0]});const u=ic(e);u.children=[d],delete e.children[o.id],delete e.blockEditorsMap[o.id],e.blockEditorsMap[l.id]=u,e.children[l.id]=l,l.value=u.children;const f=l.id;e.children=ql(e.children),e.applyChanges(),e.emit("change",e.children),null==s||s(e,l.id),(null==n?void 0:n.focus)&&e.focusBlock(f,{slate:u,waitExecution:!0})}function kc(e,t){if(!(null==t?void 0:t.id)&&!(null==t?void 0:t.at))throw new Error("getBlock requires either an id or at");if(null==t?void 0:t.id)return e.children[null==t?void 0:t.id];const n=Object.keys(e.children).find((n=>{var o;return e.children[n].meta.order===(null===(o=null==t?void 0:t.at)||void 0===o?void 0:o[0])}));return n?e.children[n]:null}const Ec={insertBlock:lc,deleteBlock:cc,moveBlock:sc,focusBlock:dc,splitBlock:uc,increaseBlockDepth:fc,decreaseBlockDepth:pc,duplicateBlock:vc,updateBlock:mc,toggleBlock:bc,insertBlocks:wc,createBlock:xc,deleteBlocks:ac,getBlock:kc,getSlate:function(e,t){if(!(null==t?void 0:t.id)&&!(null==t?void 0:t.at))throw new Error("getSlate requires either an id or at");const n=(null==t?void 0:t.id)||Object.keys(e.children).find((n=>{var o;return e.children[n].meta.order===(null===(o=null==t?void 0:t.at)||void 0===o?void 0:o[0])})),o=e.blockEditorsMap[n||""],r=e.children[n||""],i=e.blocks[(null==r?void 0:r.type)||""];if(!(null==i?void 0:i.hasCustomEditor)&&!o)throw new Error(`Slate not found with params: ${JSON.stringify(t)}`);return o}};function Oc({editor:e}){const t=c(!1),n=c(!1),o=c(null),r=c(null),i=t=>{const n=t||e.selection;if(n){const t=Ec.getSlate(e,{at:n});if(!t)return;S.withoutNormalizing(t,(()=>{D.select(t,[0]),t.selection&&B.isExpanded(t.selection)&&(w.blur(t),w.deselect(t))}))}},l=l=>{var c;if(!t.current||e.readOnly)return;const a=document.elementFromPoint(l.clientX,l.clientY),s=null==a?void 0:a.closest("[data-yoopta-block]");if(s){const t=s.getAttribute("data-yoopta-block-id")||"",l=null===(c=e.children[t])||void 0===c?void 0:c.meta.order;if(n.current&&"number"==typeof l&&l===o.current)return r.current=l,void e.setBlockSelected([l],{only:!0});if("number"==typeof l&&l!==r.current){r.current=l,n.current=!0;const t=Math.min(o.current,l),c=Math.max(o.current,l);i();const a=Array.from({length:c-t+1},((e,n)=>t+n));e.setBlockSelected(a)}}},a=()=>{var i,c;t.current=!1,n.current=!1,o.current=null,r.current=null,null===(i=e.refElement)||void 0===i||i.removeEventListener("mousemove",l),null===(c=e.refElement)||void 0===c||c.removeEventListener("mouseup",a)};return{onMouseDown:n=>{var c,s,d,u,f;if(e.readOnly)return;Array.isArray(e.selectedBlocks)&&e.selectedBlocks.length>0&&!n.shiftKey&&!n.altKey&&e.setBlockSelected(null);const p=n.target.closest("[data-yoopta-block]");if(p&&0===n.button){const h=p.getAttribute("data-yoopta-block-id")||"",g=null===(c=e.children[h])||void 0===c?void 0:c.meta.order;if("number"==typeof g){if(t.current=!0,o.current=g,r.current=g,n.shiftKey&&Array.isArray(e.selection)&&g!==(null===(s=e.selection)||void 0===s?void 0:s[0]))return void(t=>{i();const n=e.selection[0],o=Array.from({length:Math.abs(t-n)}).map(((e,o)=>t>n?n+o+1:n-o-1));e.setBlockSelected([...o,n],{only:!0}),e.setSelection([t])})(g);g!==(null===(d=e.selection)||void 0===d?void 0:d[0])&&e.setSelection([g]),null===(u=e.refElement)||void 0===u||u.addEventListener("mousemove",l),null===(f=e.refElement)||void 0===f||f.addEventListener("mouseup",a)}}}}}const Cc={selectionStarted:!1,indexToSelect:null,startedIndexToSelect:null},Sc=({placeholder:n,marks:o,className:r,selectionBoxRoot:i,width:l,style:a,children:d,autoFocus:u=!0})=>{const f=$(),p=V(),h=rl({editor:f,root:i}),g=Oc({editor:f});let v=c(Cc).current;s((()=>{u&&!p&&f.focus()}),[u,p]),s((()=>{if(!p)return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)}),[f.selectedBlocks,p]);const m=()=>{v.indexToSelect=null,v.startedIndexToSelect=null,v.selectionStarted=!1},y=e=>{var t,n,o,r,i;if(!p){if(zi.isSelect(e)){if((null===(t=f.selectedBlocks)||void 0===t?void 0:t.length)===Object.keys(f.children).length)return void e.preventDefault();if(v.selectionStarted)return e.preventDefault(),void f.setBlockSelected([],{allSelected:!0})}if((zi.isCopy(e)||zi.isCut(e))&&Array.isArray(f.selectedBlocks)&&f.selectedBlocks.length>0){e.preventDefault();const t=f.getHTML(f.getEditorValue()),n=f.getPlainText(f.getEditorValue()),o=new Blob([t],{type:"text/html"}),r=new Blob([n],{type:"text/plain"}),i=new ClipboardItem({"text/html":o,"text/plain":r});if(navigator.clipboard.write([i]).then((()=>{const e=(new DOMParser).parseFromString(t,"text/html");console.log("HTML copied\n",e.body)})),zi.isCut(e)){const e=f.selectedBlocks.length===Object.keys(f.children).length;f.deleteBlocks({paths:f.selectedBlocks,focus:!1}),f.setBlockSelected(null),m(),e&&f.insertBlock(Q({id:G()}),{at:[0],focus:!0})}}else{if(zi.isBackspace(e)){e.stopPropagation();if(Array.isArray(f.selectedBlocks)&&(null===(n=f.selectedBlocks)||void 0===n?void 0:n.length)===Object.keys(f.children).length)return e.preventDefault(),f.deleteBlocks({deleteAll:!0}),f.setBlockSelected(null),void m();if(Array.isArray(f.selectedBlocks)&&(null===(o=f.selectedBlocks)||void 0===o?void 0:o.length)>0)return e.preventDefault(),f.deleteBlocks({paths:f.selectedBlocks,focus:!1}),f.setBlockSelected(null),void m()}if(zi.isShiftArrowUp(e)){if("function"==typeof e.isDefaultPrevented&&e.isDefaultPrevented())return;if(v.selectionStarted&&null!==v.startedIndexToSelect&&null!==v.indexToSelect){const e=v.indexToSelect,t=e-1;if(0===e)return;if(e===v.startedIndexToSelect)return f.setBlockSelected([t]),void(v.indexToSelect=t);if(t<v.startedIndexToSelect)return f.setBlockSelected([t]),void(v.indexToSelect=t);if((null===(r=f.selectedBlocks)||void 0===r?void 0:r.includes(e))&&e!==v.startedIndexToSelect){const n=f.selectedBlocks.filter((t=>t!==e));return f.setBlockSelected(n,{only:!0}),void(v.indexToSelect=t)}return}const t=P(f),n=Ln(f);if(!n||!n.selection||!t)return;const o=j.parent(n.selection.anchor.path),i=S.isStart(n,n.selection.focus,o);if(B.isExpanded(n.selection)&&i){const o=f.selection?[f.selection[0]-1]:[0],r=P(f,{at:o});t&&r&&(e.preventDefault(),w.blur(n),w.deselect(n),D.deselect(n),f.setSelection(null),f.setBlockSelected([null==t?void 0:t.meta.order,t.meta.order-1]),v.startedIndexToSelect=t.meta.order,v.indexToSelect=t.meta.order-1,v.selectionStarted=!0)}}if(zi.isShiftArrowDown(e)){if(v.selectionStarted&&null!==v.indexToSelect&&null!==v.startedIndexToSelect){const e=v.indexToSelect,t=e+1;if(t===Object.keys(f.children).length)return;if(e===v.startedIndexToSelect)return f.setBlockSelected([t]),void(v.indexToSelect=t);if(t>v.startedIndexToSelect)return f.setBlockSelected([t]),void(v.indexToSelect=t);if((null===(i=f.selectedBlocks)||void 0===i?void 0:i.includes(e))&&e!==v.startedIndexToSelect){const n=f.selectedBlocks.filter((t=>t!==e));return f.setBlockSelected(n,{only:!0}),void(v.indexToSelect=t)}return}const t=P(f),n=Ln(f);if(!n||!n.selection||!t)return;const o=j.parent(n.selection.anchor.path),r=S.isEnd(n,n.selection.focus,o);if(B.isExpanded(n.selection)&&r){const o=f.selection?[f.selection[0]+1]:[0],r=P(f,{at:o});t&&r&&(e.preventDefault(),w.blur(n),w.deselect(n),D.deselect(n),f.setSelection(null),f.setBlockSelected([null==t?void 0:t.meta.order,(null==t?void 0:t.meta.order)+1]),v.startedIndexToSelect=t.meta.order,v.indexToSelect=t.meta.order+1,v.selectionStarted=!0)}}if(zi.isTab(e)){const t=f.selectedBlocks;Array.isArray(t)&&t.length>0&&(e.preventDefault(),t.forEach((e=>{const t=Ec.getBlock(f,{at:[e]});f.increaseBlockDepth({blockId:null==t?void 0:t.id})})))}else if(zi.isShiftTab(e)){const t=f.selectedBlocks;Array.isArray(t)&&t.length>0&&(e.preventDefault(),t.forEach((e=>{const t=Ec.getBlock(f,{at:[e]});f.decreaseBlockDepth({blockId:null==t?void 0:t.id})})))}else;}}},b=e=>{if(!p)return;const t=e.clipboardData,n=window.getSelection();if(n&&n.rangeCount>0){const e=n.getRangeAt(0);if(e.collapsed)return;const o=e.cloneContents().querySelectorAll("[data-yoopta-block-id]");if(!o.length)return;const r=Array.from(o).reduce(((e,t)=>{const n=t.getAttribute("data-yoopta-block-id")||"",o=f.children[n];return o&&(e[n]=o),e}),{}),i=f.getHTML(r),l=f.getPlainText(r);return t.setData("text/html",i),void t.setData("text/plain",l)}},x=(k={userSelect:h.selection?"none":"auto",pointerEvents:h.selection?"none":"auto",width:l||(null==a?void 0:a.width),paddingBottom:null==a?void 0:a.paddingBottom},Object.assign(Object.assign({},k),{width:k.width||400,paddingBottom:"number"==typeof k.paddingBottom?k.paddingBottom:100}));var k;return t("div",Object.assign({ref:e=>f.refElement=e,className:r?`yoopta-editor ${r}`:"yoopta-editor",style:x,onMouseDown:e=>{p||(g.onMouseDown(e),m(),(e=>{var t;const n=f.refElement;if(!n)return;const{bottom:o}=n.getBoundingClientRect(),r=o-parseInt(getComputedStyle(n).paddingBottom,10),i=Q({id:G()});if(e.clientY>=r){const e=Object.keys(f.children).length-1,n=P(f,{at:[e]}),o=Ln(f,{at:[e]});if(n&&o&&o.selection){const e=S.string(o,o.selection.anchor.path),r=j.parent(o.selection.anchor.path),[l]=S.node(o,r);if(n.type===i.type&&A.isElement(l)&&"void"!==(null===(t=l.props)||void 0===t?void 0:t.nodeType)&&0===e.trim().length)return void f.focusBlock(n.id,{slate:o})}const r=e+1;f.insertBlock(i,{at:[r],focus:!0})}})(e))},onBlur:e=>{var t;(null===(t=f.refElement)||void 0===t?void 0:t.contains(e.relatedTarget))||p||(m(),Array.isArray(f.selectedBlocks)&&f.selectedBlocks.length>0&&f.setBlockSelected(null))},onCopy:b,onCut:b},{children:[e(ol,{editor:f,marks:o,placeholder:n}),!1!==i&&e(il,{origin:h.origin,coords:h.coords,isOpen:h.selection&&!p}),d]}))};function Dc(e,t){const n=Ln(e);if(!n)return!1;const o=S.marks(n);return!!(null==o?void 0:o[t])}function jc(e,t){const n={};return t.forEach((t=>{const o=t.type;n[o]={hotkey:t.hotkey,type:o,getValue:()=>function(e,t){const n=Ln(e);if(!n)return null;const o=S.marks(n);return null==o?void 0:o[t]}(e,o),isActive:()=>Dc(e,o),toggle:()=>function(e,t){const n=Ln(e),o=Dc(e,t);n&&(o?S.removeMark(n,t):S.addMark(n,t,!0),e.applyChanges(),e.emit("change",e.children))}(e,o),update:t=>function(e,t,n){const o=Ln(e);o&&o.selection&&B.isExpanded(o.selection)&&(S.addMark(o,t,n),e.applyChanges(),e.emit("change",e.children))}(e,o,t)}})),n}function Bc(e){const t={};return Object.keys(e.children).forEach((n=>{const o=ic(e);t[n]=o})),t}function Rc({type:e,hotkey:t,render:n}){return{type:e,hotkey:t,render:n}}const Ac=Rc({type:"fakeSelection",render:t=>e("span",Object.assign({style:{backgroundColor:"#d7e6fa"}},{children:t.children}))}),_c=(()=>{const e=G();return{[e]:Q({id:e})}})(),Nc=new q,Tc=(e,t)=>Nc.on(e,t),Mc=(e,t)=>Nc.once(e,t),Lc=(e,t)=>Nc.off(e,t),Pc=(e,t)=>Nc.emit(e,t);const Ic=({id:t,editor:n,value:o,marks:r,plugins:i,autoFocus:l,className:c,tools:a,selectionBoxRoot:s,children:u,placeholder:p,readOnly:h,width:g,style:v})=>{const m=()=>{x((e=>Object.assign(Object.assign({},e),{version:e.version+1})))},y=d((()=>r?[Ac,...r]:[Ac]),[r]),b=d((()=>i.map((e=>e.getPlugin))),[i]),[w,x]=f((()=>{n.id||(n.id=t||G()),n.applyChanges=m,n.readOnly=h||!1,y&&(n.formats=jc(n,y)),n.blocks=function(e,t){const n={};return t.forEach((t=>{var o;const r=ii(t.elements),i=null===(o=null==r?void 0:r.props)||void 0===o?void 0:o.nodeType;if("inline"!==i&&"inlineVoid"!==i){const o={};Object.keys(t.elements).forEach((e=>{const n=fi(t.elements[e],["render"]);o[e]=n}));const{display:r,placeholder:i,shortcuts:l}=t.options||{};n[t.type]={type:t.type,elements:o,hasCustomEditor:!!t.customEditor,options:{display:r,placeholder:i,shortcuts:l},isActive:()=>{const n=P(e,{at:e.selection});return(null==n?void 0:n.type)===t.type},toggle:n=>bc(e,t.type,n),create:n=>xc(e,t.type,n),update:(t,n)=>{mc(e,t,n)},delete:t=>{cc(e,t)}}}})),n}(n,b);const e=function(e){return!!e&&"object"==typeof e&&0!==Object.keys(e).length}(o);return e||void 0===o||console.error(`Initial value is not valid. Should be an object with blocks. You passed: ${JSON.stringify(o)}`),n.children=e?o:_c,n.blockEditorsMap=Bc(n),n.shortcuts=function(e){const t={};return Object.values(e.blocks).forEach((e=>{var n,o,r,i;e.options&&Array.isArray(null===(n=e.options)||void 0===n?void 0:n.shortcuts)&&(null===(o=e.options)||void 0===o?void 0:o.shortcuts.length)>0&&(null===(i=null===(r=e.options)||void 0===r?void 0:r.shortcuts)||void 0===i||i.forEach((n=>{t[n]=e})))})),t}(n),n.plugins=function(e){const t={},n={};return e.forEach((e=>{e.elements&&Object.keys(e.elements).forEach((t=>{var o;const r=e.elements[t],i=null===(o=r.props)||void 0===o?void 0:o.nodeType;"inline"!==i&&"inlineVoid"!==i||(n[t]=Object.assign(Object.assign({},r),{rootPlugin:e.type}))})),t[e.type]=e})),e.forEach((e=>{if(e.elements){const o=Object.assign(Object.assign({},e.elements),n);t[e.type]=Object.assign(Object.assign({},e),{elements:o})}})),t}(b),n.commands=function(e,t){const n={};return t.forEach((t=>{t.commands&&Object.keys(t.commands).forEach((o=>{var r;(null===(r=t.commands)||void 0===r?void 0:r[o])&&(n[o]=(...n)=>{var r;return null===(r=t.commands)||void 0===r?void 0:r[o](e,...n)})}))})),n}(n,b),n.on=Tc,n.once=Mc,n.off=Lc,n.emit=Pc,{editor:n,version:0}}));return e(F,Object.assign({editorState:w},{children:e(si,Object.assign({tools:a},{children:e(Sc,Object.assign({placeholder:p,marks:y,autoFocus:l,className:c,selectionBoxRoot:s,width:g,style:v},{children:u}))}))}))},zc=Object.assign(Object.assign({},wi),{ExtendedBlockActions:({id:o,className:r,style:i,onClick:l,children:c})=>{const a=V(),[s,d]=f(!1),{refs:u,floatingStyles:p,context:h}=Ir({placement:"bottom-start",open:s,onOpenChange:d,middleware:[Ho(),$o(),Fo(),Eo(10)],whileElementsMounted:zo}),{isMounted:g,styles:v}=Hr(h,{duration:100}),m=Object.assign(Object.assign({},v),p);return a?null:t(n,{children:[g&&e(bi,Object.assign({isOpen:!0,onClose:()=>d(!1),refs:u,style:m},{children:c})),e("button",Object.assign({type:"button",contentEditable:!1,ref:u.setReference,id:o,className:`yoopta-button yoopta-extended-block-actions ${r||""}`,onClick:()=>{null==l||l(),d(!0)},style:s?Object.assign(Object.assign({},i),{opacity:1}):i},{children:e(Zr,{})}))]})},Portal:hi,Overlay:pi});function Fc(e,t){const n=Object.keys(e.children),{type:o}=t||{},r=n.find((t=>e.children[t].type===o));return r?e.children[r]:null}function $c(e,t){var n;const o=[];return t.forEach((t=>{if(t.nodeType===Node.TEXT_NODE&&o.push({text:t.textContent||""}),t.nodeType===Node.ELEMENT_NODE){const n=t;"P"!==n.nodeName&&"SPAN"!==n.nodeName&&"DIV"!==n.nodeName||o.push(Object.assign({},$c(e,n.childNodes)[0])),"B"!==n.nodeName&&"STRONG"!==n.nodeName||o.push(Object.assign({bold:!0},$c(e,n.childNodes)[0])),"I"!==n.nodeName&&"EM"!==n.nodeName||o.push(Object.assign({italic:!0},$c(e,n.childNodes)[0])),"S"!==n.nodeName&&"STRIKE"!==n.nodeName||o.push(Object.assign({strike:!0},$c(e,n.childNodes)[0])),"U"!==n.nodeName&&"INS"!==n.nodeName||o.push(Object.assign({underline:!0},$c(e,n.childNodes)[0])),"CODE"===n.nodeName&&o.push(Object.assign({code:!0},$c(e,n.childNodes)[0])),"A"===n.nodeName&&o.push({id:G(),type:"link",props:{url:n.getAttribute("href")||"",target:n.getAttribute("target")||"",rel:n.getAttribute("rel")||""},children:$c(e,n.childNodes)})}})),0!==o.length||(null===(n=o[0])||void 0===n?void 0:n.text)||o.push({text:""}),o}function Hc(e){return e.map((e=>{if("text"in e){let t=e.text;return e.bold&&(t=`<b>${t}</b>`),e.italic&&(t=`<i>${t}</i>`),e.strike&&(t=`<s>${t}</s>`),e.underline&&(t=`<u>${t}</u>`),e.code&&(t=`<code>${t}</code>`),t}if("link"===e.type){const{url:t,target:n,rel:o}=e.props;return`<a href="${t}" target="${n}" rel="${o}">${Hc(e.children)}</a>`}return""})).join("")}function Uc(e){return e.map((e=>{if("text"in e){let t=e.text;return e.bold&&(t=`**${t}**`),e.italic&&(t=`*${t}*`),e.strike&&(t=`~~${t}~~`),e.underline&&(t=`<u>${t}</u>`),e.code&&(t=`\`${t}\``),t}if("link"===e.type){const{url:t,target:n,rel:o}=e.props;return`[${Uc(e.children)}](${t})`}return""})).join("")}function Vc(e){return Array.from(new Set(e))}function Kc(e,t){try{w.blur(t),w.deselect(t),D.deselect(t)}catch(e){}e.setBlockSelected(null),e.setSelection(null)}const Wc={underline:{type:"underline",tag:"U"},strike:{type:"strike",tag:"S"},code:{type:"code",tag:"CODE"},italic:{type:"italic",tag:"I"},bold:{type:"bold",tag:"B"}};function Yc(e,t){return e.map((e=>{var n,o;let r="";if(e.text)return r=Object.keys(Wc).reduce(((t,n)=>e[n]?`<${Wc[n].tag}>${t}</${Wc[n].tag}>`:t),e.text),r;if(e.type){const i=function(e,t){return Object.values(e).find((e=>{var n,o;return e.type===(null===(o=null===(n=e.elements)||void 0===n?void 0:n[t])||void 0===o?void 0:o.rootPlugin)}))}(t,e.type);if(i&&(null===(o=null===(n=i.parsers)||void 0===n?void 0:n.html)||void 0===o?void 0:o.serialize))return r=i.parsers.html.serialize(e,Yc(e.children,t)),r}return r})).join("")}function Xc(e,t){const n=Object.values(t).filter((t=>{var n;return!(Array.isArray(e.selectedBlocks)&&e.selectedBlocks.length>0)||(null===(n=e.selectedBlocks)||void 0===n?void 0:n.includes(t.meta.order))})).sort(((e,t)=>e.meta.order-t.meta.order)).map((t=>{var n,o;const r=e.plugins[t.type];if(r&&(null===(o=null===(n=r.parsers)||void 0===n?void 0:n.html)||void 0===o?void 0:o.serialize)){const n=Yc(t.value[0].children,e.plugins);return r.parsers.html.serialize(t.value[0],n,t.meta)}return""}));return`<body id="yoopta-clipboard" data-editor-id="${e.id}">${n.join("")}</body>`}function qc(){const e={id:"",children:{},selection:null,selectedBlocks:null,readOnly:!1,isEmpty:()=>function(e){const t=Object.values(e.children);if(t.length>1)return!1;const n=t[0];if(!n)return!0;if("Paragraph"!==n.type)return!1;const o=Ln(e,{at:[n.meta.order]});if(!o)return!0;try{return!(S.string(o,[0]).length>0)}catch(e){return!0}}(e),getEditorValue:()=>function(e){return e.applyChanges(),e.children}(e),setEditorValue:(...t)=>function(e,t){e.children=t,e.blockEditorsMap=Bc(e),e.applyChanges(),e.emit("change",e.children)}(e,...t),applyChanges:()=>{},insertBlock:(...t)=>lc(e,...t),insertBlocks:(...t)=>wc(e,...t),deleteBlocks:(...t)=>ac(e,...t),deleteBlock:(...t)=>cc(e,...t),duplicateBlock:(...t)=>vc(e,...t),toggleBlock:(...t)=>bc(e,...t),increaseBlockDepth:(...t)=>fc(e,...t),decreaseBlockDepth:(...t)=>pc(e,...t),moveBlock:(...t)=>sc(e,...t),focusBlock:(...t)=>dc(e,...t),getBlock:(...t)=>kc(e,...t),updateBlock:(...t)=>mc(e,...t),splitBlock:(...t)=>uc(e,...t),setSelection:(...t)=>function(e,t,n={}){const{applyChanges:o=!0}=n;e.selection=t,o&&e.applyChanges()}(e,...t),setBlockSelected:(...t)=>function(e,t,n={}){const{only:o=!1,allSelected:r=!1}=n,i=e.selectedBlocks||[];if(null===t)e.selectedBlocks=null;else if(t.length>1)e.selectedBlocks=t;else if(o)e.selectedBlocks=t;else if(r){const t=Object.keys(e.children).map(((e,t)=>t));e.selectedBlocks=Vc(t)}else e.selectedBlocks=Vc(i.concat(t));e.applyChanges()}(e,...t),blockEditorsMap:{},blocks:{},formats:{},shortcuts:{},plugins:{},commands:{},on:(e,t)=>{},off:(e,t)=>{},emit:(e,...t)=>{},once:(e,t)=>{},isFocused:()=>function(e){return!!Hi.get(e)}(e),focus:()=>function(e){if(e.readOnly)return;const t=P(e,{at:[0]});t&&(Hi.set(e,!0),e.focusBlock(t.id,{waitExecution:!0}),e.emit("focus",!0))}(e),blur:(...t)=>function(e,t={}){var n;const o=null!==(n=t.slate)&&void 0!==n?n:Ln(e);if(!o)return;const{waitExecution:r,waitExecutionMs:i}=t;r?setTimeout((()=>Kc(e,o)),i):(Hi.set(e,!1),Kc(e,o),e.emit("blur",!1),e.applyChanges())}(e,...t),getHTML:t=>Xc(e,t),getMarkdown:t=>function(e,t){return function(e,t){return t.sort(((e,t)=>e.meta.order>t.meta.order?1:-1)).map((t=>{var n,o;const r=e.plugins[t.type];if(r){const e=t.value[0];if(null===(o=null===(n=r.parsers)||void 0===n?void 0:n.markdown)||void 0===o?void 0:o.serialize){const t=r.parsers.markdown.serialize(e,e.children.map((e=>e.text)).join(""));if(t)return t}}return""})).join("\n")}(e,Object.values(t))}(e,t),getPlainText:t=>function(e,t){const n=Xc(e,t),o=document.createElement("div");return o.innerHTML=n,o.innerText}(e,t),refElement:null};return e}function Zc(e,t,n){const o=e.children[t];if(!o)throw new Error(`Block with id ${t} not found`);const r=Ln(e,{at:[o.meta.order]});if(!r)return void console.warn("No slate found");let i=e=>A.isElement(e);(null==n?void 0:n.type)&&(i=e=>A.isElement(e)&&e.type===(null==n?void 0:n.type));try{const[e]=S.nodes(r,{at:(null==n?void 0:n.path)||r.selection||[0],match:i,mode:"lowest"});return e}catch(e){}}function Gc(e,t,n){const o=Zc(e,t,n);if(o)return o[0]}const Jc={createElement:function(e,t,n,o){const r=e.children[t];if(!r)throw new Error(`Block with id ${t} not found`);const i=Ln(e,{at:[r.meta.order]});i?S.withoutNormalizing(i,(()=>{const l=e.blocks[r.type],c=l.elements[n.type],a=J({type:n.type,props:Object.assign(Object.assign({},c.props),n.props)}),s=Object.keys(l.elements);let d=[];s.forEach((e=>{const t=l.elements[e];e===n.type&&Array.isArray(t.children)&&t.children.length>0&&t.children.forEach((e=>{const t=l.elements[e];d.push(J({type:e,props:t.props}))}))})),d.length>0&&(a.children=d);const{path:u,focus:f=!0}=o||{};let p;const h=Zc(e,t,{type:n.type});if(h){const[,e]=h;j.isPath(u)?p=u:"prev"===u?p=j.previous(e):"next"===u&&(p=j.next(e))}if(D.insertNodes(i,a,{at:p,select:f}),f&&d.length>0){const n=d[0],o=Zc(e,t,{path:p,type:n.type});if(o){const[,e]=o;D.select(i,e)}}e.applyChanges(),e.emit("change",e.children)})):console.warn("No slate found")},deleteElement:function(e,t,n){const o=e.children[t];if(!o)throw new Error(`Block with id ${t} not found`);const r=Ln(e,{at:[o.meta.order]});r?S.withoutNormalizing(r,(()=>{D.removeNodes(r,{at:n.path,match:e=>A.isElement(e)&&e.type===n.type}),e.applyChanges(),e.emit("change",e.children)})):console.warn("No slate found")},updateElement:function(e,t,n,o){const r=e.children[t];if(!r)throw new Error(`Block with id ${t} not found`);const i=Ln(e,{at:[r.meta.order]});i?S.withoutNormalizing(i,(()=>{const[t]=S.nodes(i,{at:(null==o?void 0:o.path)||[0],match:e=>A.isElement(e)&&e.type===n.type}),r=null==t?void 0:t[0],l=null==t?void 0:t[1],c=(null==r?void 0:r.props)||{},a={props:Object.assign(Object.assign({},c),n.props)};D.setNodes(i,a,{at:(null==o?void 0:o.path)||l||[0],match:e=>A.isElement(e)&&e.type===n.type,mode:"lowest"}),e.applyChanges(),e.emit("change",e.children)})):console.warn("No slate found")},insertElementText:function(e,t,n){const{blockId:o,focus:r}=n||{},i=o?e.children[o]:P(e);if(!i)return void console.warn(`To set text programmatically, you must provide a valid blockId. Got: ${o}`);const l=Ln(e,{at:[i.meta.order]});if(!l)return void console.warn("No slate found");const c=e.blocks[i.type],a=Array.from({length:Object.keys(c.elements).length},(e=>0));let s=l.selection||a;s?S.withoutNormalizing(l,(()=>{B.isRange(s)&&!B.isCollapsed(s)&&D.collapse(l,{edge:"end"}),D.insertText(l,t,{at:s}),e.applyChanges(),e.emit("change",e.children),r&&e.focusBlock(i.id,{waitExecution:!0,shouldUpdateBlockSelection:!0})})):console.warn("No valid path or selection found for text insertion")},getElement:Gc,getElementChildren:function(e,t,n){const o=Gc(e,t,n);if(o)return o.children},getElementEntry:Zc,isElementEmpty:function(e,t,n){const o=e.children[t];if(!o)throw new Error(`Block with id ${t} not found`);const r=Ln(e,{at:[o.meta.order]});if(!r)return void console.warn("No slate found");const[i]=S.nodes(r,{at:n.path||r.selection,match:e=>A.isElement(e)&&e.type===n.type});if(i){const[e,t]=i;return 0===S.string(r,t).trim().length}return!1},getElementPath:function(e,t,n){const o=e.children[t];if(!o)throw new Error(`Block with id ${t} not found`);const r=Ln(e,{at:[o.meta.order]});if(r)try{return w.findPath(r,n)}catch(e){}else console.warn("No slate found")},getParentElementPath:function(e,t,n){const o=e.children[t];if(!o)throw new Error(`Block with id ${t} not found`);const r=Ln(e,{at:[o.meta.order]});if(!r)return console.warn("No slate found"),[];try{const e=w.findPath(r,n);return j.parent(e)}catch(e){}}};!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&o.firstChild?o.insertBefore(r,o.firstChild):o.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}(".yoo-editor-z-\\[100\\]{z-index:100}.yoo-editor-mr-2{margin-right:.5rem}.yoo-editor-h-4{height:1rem}.yoo-editor-w-4{width:1rem}.yoopta-editor *{border:0 solid #e5e7eb;box-sizing:border-box;scrollbar-color:#d3d1cb transparent}::-moz-selection{background:#c6ddf8}::selection{background:#c6ddf8}.yoopta-placeholder:after{color:inherit;content:attr(data-placeholder);font-size:75%;font-style:inherit;font-weight:inherit;opacity:.5;padding-left:5px;position:absolute;text-indent:2px;top:50%;transform:translateY(-50%);-webkit-user-select:none;-moz-user-select:none;user-select:none}.yoopta-button{background-color:transparent;border-style:none;cursor:pointer}.yoopta-block{border-radius:.25rem;margin-bottom:1px;margin-top:2px;padding:0 2px;position:relative}.yoopta-selection-block{background-color:#2383e224;border-radius:.25rem;height:100%;left:0;opacity:1;pointer-events:none;position:absolute;top:0;width:100%;z-index:90}.yoopta-block-actions{display:flex;left:-50px;opacity:0;position:absolute;top:2px;transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.yoopta-block-actions[data-hovered-state-open=true]{opacity:1}.yoopta-block-actions-plus{align-items:center;background-color:inherit;background-color:transparent;border-radius:6px;border-style:none;color:#37352f59;cursor:pointer;display:flex;height:24px;justify-content:center;margin:0 1px;padding:0;position:relative;transition-duration:.18s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);width:24px}.yoopta-block-actions-plus:active,.yoopta-block-actions-plus:focus,.yoopta-block-actions-plus:hover{background-color:#37362f14}.yoopta-block-actions-drag{align-items:center;background-color:inherit;background-color:transparent;border-radius:6px;border-style:none;color:#37352f59;cursor:pointer;display:flex;height:24px;justify-content:center;margin:0 1px;padding:0;position:relative;transition-duration:.18s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);width:18px}.yoopta-block-actions-drag:active,.yoopta-block-actions-drag:focus,.yoopta-block-actions-drag:hover{background-color:#37362f14}.yoopta-slate:focus{outline:2px solid transparent;outline-offset:2px}.yoopta-slate:focus-visible{outline:2px solid transparent;outline-offset:2px}.yoopta-block-options-button{background-color:transparent;border-radius:.125rem;border-style:none;cursor:pointer;display:flex;justify-content:flex-start;line-height:120%;margin-left:4px;margin-right:4px;padding:.375rem .5rem;width:100%}.yoopta-block-options-button:hover{background-color:#37352f14}.yoopta-block-options-item{align-items:center;cursor:default;display:flex;font-size:.875rem;line-height:1.25rem;outline:2px solid transparent;outline-offset:2px;position:relative;transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);-webkit-user-select:none;-moz-user-select:none;user-select:none}.yoopta-block-options-item[data-disabled]{opacity:.5;pointer-events:none}.yoopta-extended-block-actions{--tw-bg-opacity:1;align-items:center;background-color:rgb(238 238 238/var(--tw-bg-opacity));border-radius:2px;border-style:none;cursor:pointer;display:flex;height:22px;justify-content:space-between;opacity:1;padding:0 4px;position:absolute;right:8px;top:8px;transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-timing-function:cubic-bezier(.4,0,1,1);width:22px;z-index:10}.yoopta-block-options-separator{background-color:#37352f14;height:1px;margin-bottom:4px;margin-top:4px;width:100%}.yoopta-block-options-menu-content{--tw-border-opacity:1;--tw-bg-opacity:1;--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);background-color:rgb(255 255 255/var(--tw-bg-opacity));border-color:rgb(229 231 235/var(--tw-border-opacity));border-radius:.375rem;border-style:solid;border-width:1px;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);min-width:200px;overflow:hidden;padding:6px 0;position:relative;width:auto}.yoopta-block-options-group{display:flex;flex-direction:column}.yoopta-align-left{justify-content:flex-start;text-align:left}.yoopta-align-center{justify-content:center;text-align:center}.yoopta-align-right{justify-content:flex-end;text-align:right}");export{Ec as Blocks,Jc as Elements,zi as HOTKEYS,zc as UI,L as YooptaPlugin,Q as buildBlockData,J as buildBlockElement,ci as buildBlockElementsStructure,qc as createYooptaEditor,Rc as createYooptaMark,Ic as default,$c as deserializeTextNodes,P as findPluginBlockBySelectionPath,Fc as findPluginBlockByType,Ln as findSlateBySelectionPath,G as generateId,ii as getRootBlockElement,ri as getRootBlockElementType,Hc as serializeTextNodes,Uc as serializeTextNodesIntoMarkdown,H as useBlockData,W as useBlockSelected,$ as useYooptaEditor,U as useYooptaFocused,K as useYooptaPluginOptions,V as useYooptaReadOnly,di as useYooptaTools};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoopta/editor",
3
- "version": "4.8.3-rc.0",
3
+ "version": "4.8.4-rc.0",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -67,5 +67,5 @@
67
67
  "url": "https://github.com/Darginec05/Yoopta-Editor/issues"
68
68
  },
69
69
  "homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
70
- "gitHead": "3ebd29556ec23ec77961e72d1278a987ca6e99df"
70
+ "gitHead": "846542a919e641d86b0ef45c3208f00c00b62e68"
71
71
  }