@yoopta/editor 4.6.5-rc.2 → 4.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/YooptaEditor.d.ts +2 -1
- package/dist/YooptaEditor.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/YooptaEditor.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
2
|
import { YooEditor, YooptaContentValue } from './editor/types';
|
|
3
|
+
import { PluginElementProps } from './plugins/types';
|
|
3
4
|
import { Tools } from './contexts/YooptaContext/ToolsContext';
|
|
4
5
|
import { YooptaPlugin } from './plugins';
|
|
5
6
|
import { YooptaMark } from './marks';
|
|
6
7
|
type Props = {
|
|
7
8
|
id?: string;
|
|
8
9
|
editor: YooEditor;
|
|
9
|
-
plugins: YooptaPlugin[];
|
|
10
|
+
plugins: YooptaPlugin<string, PluginElementProps<any>, Record<string, unknown>>[];
|
|
10
11
|
marks?: YooptaMark<any>[];
|
|
11
12
|
value?: YooptaContentValue;
|
|
12
13
|
autoFocus?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YooptaEditor.d.ts","sourceRoot":"","sources":["../src/YooptaEditor.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAqB,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,SAAS,EAAmB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"YooptaEditor.d.ts","sourceRoot":"","sources":["../src/YooptaEditor.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAqB,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,SAAS,EAAmB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAU,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAiB,MAAM,uCAAuC,CAAC;AAQ7E,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAIrC,KAAK,KAAK,GAAG;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,YAAY,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAClF,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC;IACpF,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAgCF,QAAA,MAAM,YAAY,mKAef,KAAK,4CAuFP,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,4 +10,4 @@ var Xo=["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 Wl(e){return"[object Object]"===Object.prototype.toString.call(e)}var Kl={isHistory(e){return!1!==Wl(t=e)&&(void 0===(n=t.constructor)||!1!==Wl(o=n.prototype)&&!1!==o.hasOwnProperty("isPrototypeOf"))&&Array.isArray(e.redos)&&Array.isArray(e.undos)&&(0===e.redos.length||A.isOperationList(e.redos[0].operations))&&(0===e.undos.length||A.isOperationList(e.undos[0].operations));var t,n,o}},Yl=new WeakMap,Xl=new WeakMap,ql={isHistoryEditor:e=>Kl.isHistory(e.history)&&S.isEditor(e),isMerging:e=>Xl.get(e),isSaving:e=>Yl.get(e),redo(e){e.redo()},undo(e){e.undo()},withoutMerging(e,t){var n=ql.isMerging(e);Xl.set(e,!1),t(),Xl.set(e,n)},withoutSaving(e,t){var n=ql.isSaving(e);Yl.set(e,!1),t(),Yl.set(e,n)}},Zl=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),ql.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];ql.withoutSaving(t,(()=>{S.withoutNormalizing(t,(()=>{var e=o.operations.map(A.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=ql.isSaving(t),s=ql.isMerging(t);if(null==a&&(a=Jl(e)),a){if(null==s&&(s=null!=l&&(0!==o.length||Gl(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},Gl=(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)),Jl=(e,t)=>"set_selection"!==e.type;function Ql(e,t,n){e.children=Vl(e.children);const o=L(e);if(!o)throw new Error(`No block found in the current selection path. Passed path: ${e.selection}`);const r=(null==n?void 0:n.slate)||Nn(e,{at:[null==o?void 0:o.meta.order]});if(!r||!r.selection)return;const i=e.blocks[t],l=function(e,t){const n=e.blocks[t].elements,o=oi(n);if(!o)throw new Error(`Root element type not found for block type ${t}`);const r=n[o];return{id:Z(),type:o,props:r.props,children:r.children&&r.children.length>0?ii(r,n):[{text:""}]}}(e,t);(null==n?void 0:n.deleteText)&&D.delete(r,{at:[0,0]});const c=J({id:o.id,type:i.type,meta:{order:o.meta.order,depth:o.meta.depth,align:o.meta.align},value:[l]});r.children=c.value;const a=c.id;e.children[a]=c,e.blockEditorsMap[a]=r,e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children),(null==n?void 0:n.focus)&&e.focusBlock(a,{slate:r,waitExecution:!0})}function ec(e,t){const n=Nn(e);if(!n)return!1;const o=S.marks(n);return!!(null==o?void 0:o[t])}const tc=(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=>_.isElement(e)&&S.isBlock(t,e),mode:"lowest"});if(!c)return;const[,a]=c,s=S.parent(t,a),[d]=s;if(_.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 h.create({deleteText:!1})}n(o)},t};function nc(e,t,n){e.children=Vl(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=$l(e.children),o&&e.applyChanges(),e.emit("change",e.children))}const oc="Paragraph";function rc(e,t,n){e.children=Vl(e.children);const o=L(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=oc);const i=Nn(e,{at:[o.meta.order]});if(!i)throw new Error(`Slate not found for block in position ${o.meta.order}`);const l=oi(e.blocks[r].elements);S.withoutNormalizing(i,(()=>{D.setNodes(i,{type:l},{at:[0],mode:"lowest",match:e=>_.isElement(e)&&!S.isInline(i,e)}),(null==n?void 0:n.deleteText)&&D.delete(i,{at:[0,0]});const t={id:o.id,type:r,meta:Object.assign(Object.assign({},o.meta),{order:o.meta.order}),value:i.children};e.blockEditorsMap[o.id]=i,e.children[o.id]=t,e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children),(null==n?void 0:n.focus)&&e.focusBlock(t.id,{slate:i})}))}function ic(e,t={}){const{at:n=e.selection,deleteAll:o=!1,fromPaths:r,focus:i}=t;if(Array.isArray(r)&&r.length>0){e.children=Vl(e.children),r.forEach((t=>{const n=L(e,{at:[t]});n&&(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=$l(e.children),e.applyChanges(),void e.emit("change",e.children)}if(o||1===Object.keys(e.children).length){e.children={},e.blockEditorsMap={};const t=J({id:Z()}),n=function(e){return tc(e,Zl(C(M())))}(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=Vl(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&&(delete e.children[a],delete e.blockEditorsMap[a]),e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children),i){const n=e.selection?e.selection[0]-1:0,o=L(e,{at:[n]});o&&e.focusBlock(o.id,{focusAt:t.focusAt})}}function lc(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=Nn(e);if(!n)return null;const o=S.marks(n);return null==o?void 0:o[t]}(e,o),isActive:()=>ec(e,o),toggle:()=>function(e,t){const n=Nn(e),o=ec(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=Nn(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 cc(e){const t={};return Object.keys(e.children).forEach((n=>{const o=ac(e);t[n]=o})),t}function ac(e){return tc(e,Zl(C(M())))}function sc(e,t,n={}){e.children=Vl(e.children);const{at:o=null,focus:r=!1,slate:i=null}=n,l=L(e),c=o,a={id:Z(),value:t.value,type:t.type,meta:Object.assign(Object.assign({},t.meta),{order:0})};let s=!1;if(i&&i.selection){const e=S.string(i,i.selection.anchor.path);s=S.isStart(i,i.selection.anchor,i.selection.anchor.path)&&e.length>0}if(c){const[t]=c;Object.values(e.children).forEach((e=>{e.meta.order>=t&&(e.meta.order+=1)})),a.meta.order=t}else{const t=Object.keys(e.children).length;a.meta.order=t}const d=ac(e);e.blockEditorsMap[a.id]=d,s&&l&&(a.meta.order=l.meta.order,l.meta.order+=1),e.children[a.id]=a;const u=null==l?void 0:l.id;e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children),r&&e.focusBlock(s&&u?u:a.id)}function dc(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=J({id:Z()}),n=function(e){return tc(e,Zl(C(M())))}(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=Vl(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=$l(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=Vl(e.children),o.forEach((t=>{const n=L(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=$l(e.children),e.applyChanges(),e.emit("change",e.children),void(i&&e.focusBlock(t[0],{waitExecution:!0}))}}function uc(e,t,n){e.children=Vl(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=$l(e.children),e.applyChanges(),e.emit("change",e.children)}function fc(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(T.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 pc(e,t={}){const{slate:n,focus:o=!0}=t,r=L(e);n&&n.selection&&r&&S.withoutNormalizing(n,(()=>{e.children=Vl(e.children);const t=j.parent(n.selection.anchor.path);D.splitNodes(n,{at:n.selection,match:e=>_.isElement(e),always:!0,mode:"highest"});const i=t[0]+1,l=n.children.slice()[i];D.removeNodes(n,{at:[i],match:e=>_.isElement(e),mode:"highest"});const c={id:Z(),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=ac(e);e.blockEditorsMap[c.id]=a,e.children[c.id]=c,e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children),o&&e.focusBlock(c.id,{slate:a})}))}function hc(e,t={}){const{at:n=e.selection,blockId:o=""}=t;if(!o&&!n)return;e.children=Vl(e.children);const r=e.children[o]||L(e);r&&(r.meta.depth=r.meta.depth+1,e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children))}function gc(e,t={}){const{at:n=e.selection,blockId:o=""}=t;if(!o&&!n)return;e.children=Vl(e.children);const r=e.children[o]||L(e);r&&(r.meta.depth=0===r.meta.depth?0:r.meta.depth-1,e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children))}var vc={};!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]",y="[object WeakMap]",m="[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\]$/,_=/^(?:0|[1-9]\d*)$/,A={};A[r]=A["[object Array]"]=A[m]=A[b]=A[i]=A[l]=A[w]=A[x]=A[k]=A[E]=A[O]=A[s]=A[d]=A[u]=A[p]=A[h]=A[g]=A[v]=A[C]=A[S]=A[D]=A[j]=!0,A["[object Error]"]=A[c]=A[y]=!1;var M="object"==typeof K&&K&&K.Object===Object&&K,T="object"==typeof self&&self&&self.Object===Object&&self,N=M||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 H(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 U(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function V(e){var t=-1,n=Array(e.size);return e.forEach((function(e,o){n[++t]=[o,e]})),n}function $(e,t){return function(n){return e(t(n))}}function W(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var Y,X=Array.prototype,q=Function.prototype,Z=Object.prototype,G=N["__core-js_shared__"],J=(Y=/[^.]+$/.exec(G&&G.keys&&G.keys.IE_PROTO||""))?"Symbol(src)_1."+Y:"",Q=q.toString,ee=Z.hasOwnProperty,te=Z.toString,ne=RegExp("^"+Q.call(ee).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),oe=I?N.Buffer:void 0,re=N.Symbol,ie=N.Uint8Array,le=$(Object.getPrototypeOf,Object),ce=Object.create,ae=Z.propertyIsEnumerable,se=X.splice,de=Object.getOwnPropertySymbols,ue=oe?oe.isBuffer:void 0,fe=$(Object.keys,Object),pe=Ie(N,"DataView"),he=Ie(N,"Map"),ge=Ie(N,"Promise"),ve=Ie(N,"Set"),ye=Ie(N,"WeakMap"),me=Ie(Object,"create"),be=Ve(pe),we=Ve(he),xe=Ve(ge),ke=Ve(ve),Ee=Ve(ye),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=We(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&Ke(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||He(l,o))||n.push(l);return n}function _e(e,t,n){var o=e[t];ee.call(e,t)&&$e(o,n)&&(void 0!==n||t in e)||(e[t]=n)}function Ae(e,t){for(var n=e.length;n--;)if($e(e[n][0],t))return n;return-1}function Me(e,t,n,o,f,y,R){var _;if(o&&(_=y?o(e,f,y,R):o(e)),void 0!==_)return _;if(!qe(e))return e;var M=We(e);if(M){if(_=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,_)}else{var T=Fe(e),N=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||N&&!y){if(U(e))return y?e:{};if(_=function(e){return"function"!=typeof e.constructor||Ue(e)?{}:(t=le(e),qe(t)?ce(t):{});var t}(N?{}:e),!t)return function(e,t){return Le(e,ze(e),t)}(e,function(e,t){return e&&Le(t,Ze(t),e)}(_,e))}else{if(!A[T])return y?e:{};_=function(e,t,n,o){var r=e.constructor;switch(t){case m:return Ne(e);case i:case l:return new r(+e);case b:return function(e,t){var n=t?Ne(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?Ne(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(V(e),!0):V(e);return H(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(W(e),!0):W(e);return H(o,F,new e.constructor)}(e,o,n);case v:return c=e,Ce?Object(Ce.call(c)):{}}var c}(e,T,Me,t)}}R||(R=new Be);var L=R.get(e);if(L)return L;if(R.set(e,_),!M)var P=n?function(e){return function(e,t,n){var o=t(e);return We(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]),_e(_,i,Me(r,t,n,o,i,e,R))})),_}function Te(e){return!(!qe(e)||(t=e,J&&J in t))&&(Xe(e)||U(e)?ne:R).test(Ve(e));var t}function Ne(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;_e(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__=me?me(null):{}},Se.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Se.prototype.get=function(e){var t=this.__data__;if(me){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 me?void 0!==t[e]:ee.call(t,e)},Se.prototype.set=function(e,t){return this.__data__[e]=me&&void 0===t?n:t,this},De.prototype.clear=function(){this.__data__=[]},De.prototype.delete=function(e){var t=this.__data__,n=Ae(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=Ae(t,e);return n<0?void 0:t[n][1]},De.prototype.has=function(e){return Ae(this.__data__,e)>-1},De.prototype.set=function(e,t){var n=this.__data__,o=Ae(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?$(de,Object):function(){return[]},Fe=function(e){return te.call(e)};function He(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||_.test(e))&&e>-1&&e%1==0&&e<t}function Ue(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Z)}function Ve(e){if(null!=e){try{return Q.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function $e(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||ye&&Fe(new ye)!=y)&&(Fe=function(e){var t=te.call(e),n=t==u?e.constructor:void 0,o=n?Ve(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 y}return t});var We=Array.isArray;function Ke(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 Ke(e)?Re(e):function(e){if(!Ue(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 Me(e,!0,!0)}}({get exports(){return vc},set exports(e){vc=e}},vc);var yc=vc;function mc(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=L(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=Vl(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):yc(l));var l;const c=ac(e);i.id=Z(),i.meta.order=r.meta.order+1,e.children[i.id]=i,e.blockEditorsMap[i.id]=c;const a=i.id;e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children),o&&e.focusBlock(a,{waitExecution:!0})}function bc(e,t,n={}){e.children=Vl(e.children);const{at:o,focus:r}=n;let i=o||[0];const l=L(e),c=Nn(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=ac(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=$l(e.children),e.applyChanges(),e.emit("change",e.children),r&&e.setBlockSelected(d)}function wc(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 xc={insertBlock:sc,deleteBlock:ic,moveBlock:uc,focusBlock:fc,splitBlock:pc,increaseBlockDepth:hc,decreaseBlockDepth:gc,duplicateBlock:mc,updateBlock:nc,toggleBlock:rc,insertBlocks:bc,deleteBlocks:dc,getBlock:wc},kc={selectionStarted:!1,indexToSelect:null,startedIndexToSelect:null},Ec=({placeholder:n,marks:o,className:r,selectionBoxRoot:i,width:l,style:a,children:d,autoFocus:u=!0})=>{const f=F(),p=V(),h=c(null),g=Qi({editor:f,yooptaEditorRef:h,root:i});let v=c(kc).current;s((()=>{u&&!p&&f.focus()}),[u,p]),s((()=>{if(!p)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)}),[f.selectedBlocks,p]);const y=()=>{p||Array.isArray(f.selectedBlocks)&&f.selectedBlocks.length>0&&f.setBlockSelected(null)},m=()=>{v.indexToSelect=null,v.startedIndexToSelect=null,v.selectionStarted=!1},b=e=>{var t,n,o,r,i;if(!p){if(Li.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((Li.isCopy(e)||Li.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)})),Li.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(J({id:Z()}),{at:[0],focus:!0})}}else{if(Li.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(Li.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=L(f),n=Nn(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=L(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(Li.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=L(f),n=Nn(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=L(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(Li.isTab(e)){const t=f.selectedBlocks;Array.isArray(t)&&t.length>0&&(e.preventDefault(),t.forEach((e=>{const t=xc.getBlock(f,{at:[e]});f.increaseBlockDepth({blockId:null==t?void 0:t.id})})))}else if(Li.isShiftTab(e)){const t=f.selectedBlocks;Array.isArray(t)&&t.length>0&&(e.preventDefault(),t.forEach((e=>{const t=xc.getBlock(f,{at:[e]});f.decreaseBlockDepth({blockId:null==t?void 0:t.id})})))}else;}}},x=(k={userSelect:g.selection?"none":"auto",pointerEvents:g.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({"data-yoopta-editor-id":f.id,className:r?`yoopta-editor ${r}`:"yoopta-editor",style:x,ref:h,onMouseDown:e=>{p||(m(),(e=>{var t;const n=h.current;if(!n)return;const{bottom:o}=n.getBoundingClientRect(),r=o-parseInt(getComputedStyle(n).paddingBottom,10),i=J({id:Z()});if(e.clientY>=r){const e=Object.keys(f.children).length-1,n=L(f,{at:[e]}),o=Nn(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&&_.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),y())},onBlur:e=>{var t;(null===(t=h.current)||void 0===t?void 0:t.contains(e.relatedTarget))||p||(m(),y())}},{children:[e(Ji,{editor:f,marks:o,placeholder:n}),!1!==i&&e(el,{origin:g.origin,coords:g.coords,isOpen:g.selection&&!p}),d]}))},Oc=({children:e,fallback:t=null})=>{const[n,o]=f(!1);return s((()=>o(!0)),[]),n?e:t};function Cc({type:e,hotkey:t,render:n}){return{type:e,hotkey:t,render:n}}const Sc=Cc({type:"fakeSelection",render:t=>e("span",Object.assign({style:{backgroundColor:"#d7e6fa"}},{children:t.children}))}),Dc=(()=>{const e=Z();return{[e]:J({id:e})}})(),jc=new X,Bc=(e,t)=>jc.on(e,t),Rc=(e,t)=>jc.once(e,t),_c=(e,t)=>jc.off(e,t),Ac=(e,t)=>jc.emit(e,t);const Mc=({id:n,editor:o,value:r,marks:i,plugins:l,autoFocus:c,className:a,tools:s,selectionBoxRoot:u,children:p,placeholder:h,readOnly:g,width:v,style:y})=>{const m=()=>{k((e=>Object.assign(Object.assign({},e),{version:e.version+1})))},b=d((()=>i?[Sc,...i]:[Sc]),[i]),w=d((()=>l.map((e=>e.getPlugin))),[l]),[x,k]=f((()=>{o.id||(o.id=n||Z()),o.applyChanges=m,o.readOnly=g||!1,b&&(o.formats=lc(o,b)),o.blocks=function(e,t){const n={};return t.forEach((t=>{var o;const r=ri(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=di(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=L(e,{at:e.selection});return(null==n?void 0:n.type)===t.type},toggle:n=>rc(e,t.type,n),create:n=>Ql(e,t.type,n),update:(t,n)=>{nc(e,t,n)},delete:t=>{ic(e,t)}}}})),n}(o,w);const e=function(e){return!!e&&"object"==typeof e&&0!==Object.keys(e).length}(r);return e||void 0===r||console.error(`Initial value is not valid. Should be an object with blocks. You passed: ${JSON.stringify(r)}`),o.children=e?r:Dc,o.blockEditorsMap=cc(o),o.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}(o),o.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}(w),o.on=Bc,o.once=Rc,o.off=_c,o.emit=Ac,{editor:o,version:0}}));return(e=>!!(Array.isArray(e)&&e.length>0)&&e.some((e=>{if(e.id||e.nodeType||e.type||e.children)return!0})))(r)?(console.error("Legacy version of Yoopta-Editor in use"),t("div",{children:[e("h1",{children:"Legacy version of the Yoopta-Editor is used"}),e("p",{children:"It looks like you are using a legacy version of the editor."}),t("p",{children:["The structure of value has changed in new ",e("b",{children:"@v4"})," version"]}),t("p",{children:["Please, check the migration guide to update your editor to the new ",e("b",{children:"@v4"})," version.",e("a",{href:""})]}),t("p",{children:["If you have specific case please"," ",e("a",Object.assign({href:"https://github.com/Darginec05/Yoopta-Editor/issues",target:"_blank",rel:"noopener noreferrer"},{children:"open the issue"}))," ","and we will solve your problem with migration"]})]})):e(Oc,{children:e(z,Object.assign({editorState:x},{children:e(ci,Object.assign({tools:s},{children:e(Ec,Object.assign({placeholder:h,marks:b,autoFocus:c,className:a,selectionBoxRoot:u,width:v,style:y},{children:p}))}))}))})},Tc=Object.assign(Object.assign({},yi),{ExtendedBlockActions:({id:o,className:r,style:i,onClick:l,children:c})=>{const a=V(),[s,d]=f(!1),{refs:u,floatingStyles:p,context:h}=Pr({placement:"bottom-start",open:s,onOpenChange:d,middleware:[Ho(),Fo(),zo(),ko(10)],whileElementsMounted:Io}),{isMounted:g,styles:v}=Hr(h,{duration:100}),y=Object.assign(Object.assign({},v),p);return a?null:t(n,{children:[g&&e(vi,Object.assign({isOpen:!0,onClose:()=>d(!1),refs:u,style:y},{children:c})),e("button",Object.assign({type:"button",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(qr,{})}))]})},Portal:fi,Overlay:ui});function Nc(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 Lc(e){return Array.from(new Set(e))}function Pc(e,t){try{w.blur(t),w.deselect(t),D.deselect(t)}catch(e){}}const Ic={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 zc(e,t){return e.map((e=>{var n,o;let r="";if(e.text)return r=Object.keys(Ic).reduce(((t,n)=>e[n]?`<${Ic[n].tag}>${t}</${Ic[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,zc(e.children,t)),r}return r})).join("")}function Fc(e,t){const n=Object.values(t).filter((t=>{var n;return 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=zc(t.value[0].children,e.plugins);return r.parsers.html.serialize(t.value[0],n)}return""}));return`<body id="yoopta-clipboard" data-editor-id="${e.id}">${n.join("")}</body>`}const Hc=()=>{const e={id:"",children:{},selection:null,selectedBlocks:null,readOnly:!1,getEditorValue:()=>function(e){return e.applyChanges(),e.children}(e),setEditorValue:(...t)=>function(e,t){e.children=t,e.blockEditorsMap=cc(e),e.applyChanges(),e.emit("change",e.children)}(e,...t),applyChanges:()=>{},insertBlock:(...t)=>sc(e,...t),insertBlocks:(...t)=>bc(e,...t),deleteBlocks:(...t)=>dc(e,...t),deleteBlock:(...t)=>ic(e,...t),duplicateBlock:(...t)=>mc(e,...t),toggleBlock:(...t)=>rc(e,...t),increaseBlockDepth:(...t)=>hc(e,...t),decreaseBlockDepth:(...t)=>gc(e,...t),moveBlock:(...t)=>uc(e,...t),focusBlock:(...t)=>fc(e,...t),getBlock:(...t)=>wc(e,...t),updateBlock:(...t)=>nc(e,...t),splitBlock:(...t)=>pc(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=Lc(t)}else e.selectedBlocks=Lc(i.concat(t));e.applyChanges()}(e,...t),blockEditorsMap:{},blocks:{},formats:{},shortcuts:{},plugins:{},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=L(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:Nn(e);if(!o)return;const{waitExecution:r,waitExecutionMs:i}=t;r?setTimeout((()=>Pc(0,o)),i):(Hi.set(e,!1),Pc(0,o),e.emit("blur",!1),e.applyChanges())}(e,...t),getHTML:t=>Fc(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=Fc(e,t),o=document.createElement("div");return o.innerHTML=n,o.innerText}(e,t)};return e};function Uc(e,t,n){const o=e.children[t];if(!o)throw new Error(`Block with id ${t} not found`);const r=Nn(e,{at:[o.meta.order]});if(!r)return void console.warn("No slate found");let i=e=>_.isElement(e);(null==n?void 0:n.type)&&(i=e=>_.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 Vc(e,t,n){const o=Uc(e,t,n);if(o)return o[0]}const $c={createElement:function(e,t,n,o){const r=e.children[t];if(!r)throw new Error(`Block with id ${t} not found`);const i=Nn(e,{at:[r.meta.order]});i?S.withoutNormalizing(i,(()=>{const l=e.blocks[r.type],c=l.elements[n.type],a=G({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(G({type:e,props:t.props}))}))})),d.length>0&&(a.children=d);const{path:u,focus:f=!0}=o||{};let p;const h=Uc(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=Uc(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=Nn(e,{at:[o.meta.order]});r?S.withoutNormalizing(r,(()=>{D.removeNodes(r,{at:n.path,match:e=>_.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=Nn(e,{at:[r.meta.order]});i?S.withoutNormalizing(i,(()=>{const[t]=S.nodes(i,{at:(null==o?void 0:o.path)||[0],match:e=>_.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=>_.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]:L(e);if(!i)return void console.warn(`To set text programmatically, you must provide a valid blockId. Got: ${o}`);const l=Nn(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:Vc,getElementChildren:function(e,t,n){const o=Vc(e,t,n);if(o)return o.children},getElementEntry:Uc,isElementEmpty:function(e,t,n){const o=e.children[t];if(!o)throw new Error(`Block with id ${t} not found`);const r=Nn(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=>_.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=Nn(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=Nn(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}*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}button{background-color:transparent;border:none;cursor:pointer}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}::-moz-selection{background:#c6ddf8}::selection{background:#c6ddf8}.yoopta-editor{height:auto}.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{xc as Blocks,$c as Elements,Li as HOTKEYS,Tc as UI,N as YooptaPlugin,J as buildBlockData,G as buildBlockElement,Hc as createYooptaEditor,Cc as createYooptaMark,Mc as default,L as findPluginBlockBySelectionPath,Nc as findPluginBlockByType,Nn as findSlateBySelectionPath,Z as generateId,ri as getRootBlockElement,oi as getRootBlockElementType,H as useBlockData,W as useBlockSelected,F as useYooptaEditor,U as useYooptaFocused,$ as useYooptaPluginOptions,V as useYooptaReadOnly,ai as useYooptaTools};
|
|
13
|
+
function Wl(e){return"[object Object]"===Object.prototype.toString.call(e)}var Kl={isHistory(e){return!1!==Wl(t=e)&&(void 0===(n=t.constructor)||!1!==Wl(o=n.prototype)&&!1!==o.hasOwnProperty("isPrototypeOf"))&&Array.isArray(e.redos)&&Array.isArray(e.undos)&&(0===e.redos.length||A.isOperationList(e.redos[0].operations))&&(0===e.undos.length||A.isOperationList(e.undos[0].operations));var t,n,o}},Yl=new WeakMap,Xl=new WeakMap,ql={isHistoryEditor:e=>Kl.isHistory(e.history)&&S.isEditor(e),isMerging:e=>Xl.get(e),isSaving:e=>Yl.get(e),redo(e){e.redo()},undo(e){e.undo()},withoutMerging(e,t){var n=ql.isMerging(e);Xl.set(e,!1),t(),Xl.set(e,n)},withoutSaving(e,t){var n=ql.isSaving(e);Yl.set(e,!1),t(),Yl.set(e,n)}},Zl=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),ql.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];ql.withoutSaving(t,(()=>{S.withoutNormalizing(t,(()=>{var e=o.operations.map(A.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=ql.isSaving(t),s=ql.isMerging(t);if(null==a&&(a=Jl(e)),a){if(null==s&&(s=null!=l&&(0!==o.length||Gl(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},Gl=(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)),Jl=(e,t)=>"set_selection"!==e.type;function Ql(e,t,n){e.children=Vl(e.children);const o=L(e);if(!o)throw new Error(`No block found in the current selection path. Passed path: ${e.selection}`);const r=(null==n?void 0:n.slate)||Nn(e,{at:[null==o?void 0:o.meta.order]});if(!r||!r.selection)return;const i=e.blocks[t],l=function(e,t){const n=e.blocks[t].elements,o=oi(n);if(!o)throw new Error(`Root element type not found for block type ${t}`);const r=n[o];return{id:Z(),type:o,props:r.props,children:r.children&&r.children.length>0?ii(r,n):[{text:""}]}}(e,t);(null==n?void 0:n.deleteText)&&D.delete(r,{at:[0,0]});const c=J({id:o.id,type:i.type,meta:{order:o.meta.order,depth:o.meta.depth,align:o.meta.align},value:[l]});r.children=c.value;const a=c.id;e.children[a]=c,e.blockEditorsMap[a]=r,e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children),(null==n?void 0:n.focus)&&e.focusBlock(a,{slate:r,waitExecution:!0})}function ec(e,t){const n=Nn(e);if(!n)return!1;const o=S.marks(n);return!!(null==o?void 0:o[t])}const tc=(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=>_.isElement(e)&&S.isBlock(t,e),mode:"lowest"});if(!c)return;const[,a]=c,s=S.parent(t,a),[d]=s;if(_.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 h.create({deleteText:!1})}n(o)},t};function nc(e,t,n){e.children=Vl(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=$l(e.children),o&&e.applyChanges(),e.emit("change",e.children))}const oc="Paragraph";function rc(e,t,n){e.children=Vl(e.children);const o=L(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=oc);const i=Nn(e,{at:[o.meta.order]});if(!i)throw new Error(`Slate not found for block in position ${o.meta.order}`);const l=oi(e.blocks[r].elements);S.withoutNormalizing(i,(()=>{D.setNodes(i,{type:l},{at:[0],mode:"lowest",match:e=>_.isElement(e)&&!S.isInline(i,e)}),(null==n?void 0:n.deleteText)&&D.delete(i,{at:[0,0]});const t={id:o.id,type:r,meta:Object.assign(Object.assign({},o.meta),{order:o.meta.order}),value:i.children};e.blockEditorsMap[o.id]=i,e.children[o.id]=t,e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children),(null==n?void 0:n.focus)&&e.focusBlock(t.id,{slate:i})}))}function ic(e,t={}){const{at:n=e.selection,deleteAll:o=!1,fromPaths:r,focus:i}=t;if(Array.isArray(r)&&r.length>0){e.children=Vl(e.children),r.forEach((t=>{const n=L(e,{at:[t]});n&&(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=$l(e.children),e.applyChanges(),void e.emit("change",e.children)}if(o||1===Object.keys(e.children).length){e.children={},e.blockEditorsMap={};const t=J({id:Z()}),n=function(e){return tc(e,Zl(C(M())))}(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=Vl(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&&(delete e.children[a],delete e.blockEditorsMap[a]),e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children),i){const n=e.selection?e.selection[0]-1:0,o=L(e,{at:[n]});o&&e.focusBlock(o.id,{focusAt:t.focusAt})}}function lc(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=Nn(e);if(!n)return null;const o=S.marks(n);return null==o?void 0:o[t]}(e,o),isActive:()=>ec(e,o),toggle:()=>function(e,t){const n=Nn(e),o=ec(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=Nn(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 cc(e){const t={};return Object.keys(e.children).forEach((n=>{const o=ac(e);t[n]=o})),t}function ac(e){return tc(e,Zl(C(M())))}function sc(e,t,n={}){e.children=Vl(e.children);const{at:o=null,focus:r=!1,slate:i=null}=n,l=L(e),c=o,a={id:Z(),value:t.value,type:t.type,meta:Object.assign(Object.assign({},t.meta),{order:0})};let s=!1;if(i&&i.selection){const e=S.string(i,i.selection.anchor.path);s=S.isStart(i,i.selection.anchor,i.selection.anchor.path)&&e.length>0}if(c){const[t]=c;Object.values(e.children).forEach((e=>{e.meta.order>=t&&(e.meta.order+=1)})),a.meta.order=t}else{const t=Object.keys(e.children).length;a.meta.order=t}const d=ac(e);e.blockEditorsMap[a.id]=d,s&&l&&(a.meta.order=l.meta.order,l.meta.order+=1),e.children[a.id]=a;const u=null==l?void 0:l.id;e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children),r&&e.focusBlock(s&&u?u:a.id)}function dc(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=J({id:Z()}),n=function(e){return tc(e,Zl(C(M())))}(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=Vl(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=$l(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=Vl(e.children),o.forEach((t=>{const n=L(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=$l(e.children),e.applyChanges(),e.emit("change",e.children),void(i&&e.focusBlock(t[0],{waitExecution:!0}))}}function uc(e,t,n){e.children=Vl(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=$l(e.children),e.applyChanges(),e.emit("change",e.children)}function fc(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(T.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 pc(e,t={}){const{slate:n,focus:o=!0}=t,r=L(e);n&&n.selection&&r&&S.withoutNormalizing(n,(()=>{e.children=Vl(e.children);const t=j.parent(n.selection.anchor.path);D.splitNodes(n,{at:n.selection,match:e=>_.isElement(e),always:!0,mode:"highest"});const i=t[0]+1,l=n.children.slice()[i];D.removeNodes(n,{at:[i],match:e=>_.isElement(e),mode:"highest"});const c={id:Z(),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=ac(e);e.blockEditorsMap[c.id]=a,e.children[c.id]=c,e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children),o&&e.focusBlock(c.id,{slate:a})}))}function hc(e,t={}){const{at:n=e.selection,blockId:o=""}=t;if(!o&&!n)return;e.children=Vl(e.children);const r=e.children[o]||L(e);r&&(r.meta.depth=r.meta.depth+1,e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children))}function gc(e,t={}){const{at:n=e.selection,blockId:o=""}=t;if(!o&&!n)return;e.children=Vl(e.children);const r=e.children[o]||L(e);r&&(r.meta.depth=0===r.meta.depth?0:r.meta.depth-1,e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children))}var vc={};!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]",y="[object WeakMap]",m="[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\]$/,_=/^(?:0|[1-9]\d*)$/,A={};A[r]=A["[object Array]"]=A[m]=A[b]=A[i]=A[l]=A[w]=A[x]=A[k]=A[E]=A[O]=A[s]=A[d]=A[u]=A[p]=A[h]=A[g]=A[v]=A[C]=A[S]=A[D]=A[j]=!0,A["[object Error]"]=A[c]=A[y]=!1;var M="object"==typeof K&&K&&K.Object===Object&&K,T="object"==typeof self&&self&&self.Object===Object&&self,N=M||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 H(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 U(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function V(e){var t=-1,n=Array(e.size);return e.forEach((function(e,o){n[++t]=[o,e]})),n}function $(e,t){return function(n){return e(t(n))}}function W(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var Y,X=Array.prototype,q=Function.prototype,Z=Object.prototype,G=N["__core-js_shared__"],J=(Y=/[^.]+$/.exec(G&&G.keys&&G.keys.IE_PROTO||""))?"Symbol(src)_1."+Y:"",Q=q.toString,ee=Z.hasOwnProperty,te=Z.toString,ne=RegExp("^"+Q.call(ee).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),oe=I?N.Buffer:void 0,re=N.Symbol,ie=N.Uint8Array,le=$(Object.getPrototypeOf,Object),ce=Object.create,ae=Z.propertyIsEnumerable,se=X.splice,de=Object.getOwnPropertySymbols,ue=oe?oe.isBuffer:void 0,fe=$(Object.keys,Object),pe=Ie(N,"DataView"),he=Ie(N,"Map"),ge=Ie(N,"Promise"),ve=Ie(N,"Set"),ye=Ie(N,"WeakMap"),me=Ie(Object,"create"),be=Ve(pe),we=Ve(he),xe=Ve(ge),ke=Ve(ve),Ee=Ve(ye),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=We(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&Ke(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||He(l,o))||n.push(l);return n}function _e(e,t,n){var o=e[t];ee.call(e,t)&&$e(o,n)&&(void 0!==n||t in e)||(e[t]=n)}function Ae(e,t){for(var n=e.length;n--;)if($e(e[n][0],t))return n;return-1}function Me(e,t,n,o,f,y,R){var _;if(o&&(_=y?o(e,f,y,R):o(e)),void 0!==_)return _;if(!qe(e))return e;var M=We(e);if(M){if(_=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,_)}else{var T=Fe(e),N=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||N&&!y){if(U(e))return y?e:{};if(_=function(e){return"function"!=typeof e.constructor||Ue(e)?{}:(t=le(e),qe(t)?ce(t):{});var t}(N?{}:e),!t)return function(e,t){return Le(e,ze(e),t)}(e,function(e,t){return e&&Le(t,Ze(t),e)}(_,e))}else{if(!A[T])return y?e:{};_=function(e,t,n,o){var r=e.constructor;switch(t){case m:return Ne(e);case i:case l:return new r(+e);case b:return function(e,t){var n=t?Ne(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?Ne(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(V(e),!0):V(e);return H(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(W(e),!0):W(e);return H(o,F,new e.constructor)}(e,o,n);case v:return c=e,Ce?Object(Ce.call(c)):{}}var c}(e,T,Me,t)}}R||(R=new Be);var L=R.get(e);if(L)return L;if(R.set(e,_),!M)var P=n?function(e){return function(e,t,n){var o=t(e);return We(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]),_e(_,i,Me(r,t,n,o,i,e,R))})),_}function Te(e){return!(!qe(e)||(t=e,J&&J in t))&&(Xe(e)||U(e)?ne:R).test(Ve(e));var t}function Ne(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;_e(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__=me?me(null):{}},Se.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Se.prototype.get=function(e){var t=this.__data__;if(me){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 me?void 0!==t[e]:ee.call(t,e)},Se.prototype.set=function(e,t){return this.__data__[e]=me&&void 0===t?n:t,this},De.prototype.clear=function(){this.__data__=[]},De.prototype.delete=function(e){var t=this.__data__,n=Ae(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=Ae(t,e);return n<0?void 0:t[n][1]},De.prototype.has=function(e){return Ae(this.__data__,e)>-1},De.prototype.set=function(e,t){var n=this.__data__,o=Ae(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?$(de,Object):function(){return[]},Fe=function(e){return te.call(e)};function He(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||_.test(e))&&e>-1&&e%1==0&&e<t}function Ue(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Z)}function Ve(e){if(null!=e){try{return Q.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function $e(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||ye&&Fe(new ye)!=y)&&(Fe=function(e){var t=te.call(e),n=t==u?e.constructor:void 0,o=n?Ve(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 y}return t});var We=Array.isArray;function Ke(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 Ke(e)?Re(e):function(e){if(!Ue(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 Me(e,!0,!0)}}({get exports(){return vc},set exports(e){vc=e}},vc);var yc=vc;function mc(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=L(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=Vl(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):yc(l));var l;const c=ac(e);i.id=Z(),i.meta.order=r.meta.order+1,e.children[i.id]=i,e.blockEditorsMap[i.id]=c;const a=i.id;e.children=$l(e.children),e.applyChanges(),e.emit("change",e.children),o&&e.focusBlock(a,{waitExecution:!0})}function bc(e,t,n={}){e.children=Vl(e.children);const{at:o,focus:r}=n;let i=o||[0];const l=L(e),c=Nn(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=ac(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=$l(e.children),e.applyChanges(),e.emit("change",e.children),r&&e.setBlockSelected(d)}function wc(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 xc={insertBlock:sc,deleteBlock:ic,moveBlock:uc,focusBlock:fc,splitBlock:pc,increaseBlockDepth:hc,decreaseBlockDepth:gc,duplicateBlock:mc,updateBlock:nc,toggleBlock:rc,insertBlocks:bc,deleteBlocks:dc,getBlock:wc},kc={selectionStarted:!1,indexToSelect:null,startedIndexToSelect:null},Ec=({placeholder:n,marks:o,className:r,selectionBoxRoot:i,width:l,style:a,children:d,autoFocus:u=!0})=>{const f=F(),p=V(),h=c(null),g=Qi({editor:f,yooptaEditorRef:h,root:i});let v=c(kc).current;s((()=>{u&&!p&&f.focus()}),[u,p]),s((()=>{if(!p)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)}),[f.selectedBlocks,p]);const y=()=>{p||Array.isArray(f.selectedBlocks)&&f.selectedBlocks.length>0&&f.setBlockSelected(null)},m=()=>{v.indexToSelect=null,v.startedIndexToSelect=null,v.selectionStarted=!1},b=e=>{var t,n,o,r,i;if(!p){if(Li.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((Li.isCopy(e)||Li.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)})),Li.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(J({id:Z()}),{at:[0],focus:!0})}}else{if(Li.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(Li.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=L(f),n=Nn(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=L(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(Li.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=L(f),n=Nn(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=L(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(Li.isTab(e)){const t=f.selectedBlocks;Array.isArray(t)&&t.length>0&&(e.preventDefault(),t.forEach((e=>{const t=xc.getBlock(f,{at:[e]});f.increaseBlockDepth({blockId:null==t?void 0:t.id})})))}else if(Li.isShiftTab(e)){const t=f.selectedBlocks;Array.isArray(t)&&t.length>0&&(e.preventDefault(),t.forEach((e=>{const t=xc.getBlock(f,{at:[e]});f.decreaseBlockDepth({blockId:null==t?void 0:t.id})})))}else;}}},x=(k={userSelect:g.selection?"none":"auto",pointerEvents:g.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({"data-yoopta-editor-id":f.id,className:r?`yoopta-editor ${r}`:"yoopta-editor",style:x,ref:h,onMouseDown:e=>{p||(m(),(e=>{var t;const n=h.current;if(!n)return;const{bottom:o}=n.getBoundingClientRect(),r=o-parseInt(getComputedStyle(n).paddingBottom,10),i=J({id:Z()});if(e.clientY>=r){const e=Object.keys(f.children).length-1,n=L(f,{at:[e]}),o=Nn(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&&_.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),y())},onBlur:e=>{var t;(null===(t=h.current)||void 0===t?void 0:t.contains(e.relatedTarget))||p||(m(),y())}},{children:[e(Ji,{editor:f,marks:o,placeholder:n}),!1!==i&&e(el,{origin:g.origin,coords:g.coords,isOpen:g.selection&&!p}),d]}))},Oc=({children:e,fallback:t=null})=>{const[n,o]=f(!1);return s((()=>o(!0)),[]),n?e:t};function Cc({type:e,hotkey:t,render:n}){return{type:e,hotkey:t,render:n}}const Sc=Cc({type:"fakeSelection",render:t=>e("span",Object.assign({style:{backgroundColor:"#d7e6fa"}},{children:t.children}))}),Dc=(()=>{const e=Z();return{[e]:J({id:e})}})(),jc=new X,Bc=(e,t)=>jc.on(e,t),Rc=(e,t)=>jc.once(e,t),_c=(e,t)=>jc.off(e,t),Ac=(e,t)=>jc.emit(e,t);const Mc=({id:n,editor:o,value:r,marks:i,plugins:l,autoFocus:c,className:a,tools:s,selectionBoxRoot:u,children:p,placeholder:h,readOnly:g,width:v,style:y})=>{const m=()=>{k((e=>Object.assign(Object.assign({},e),{version:e.version+1})))},b=d((()=>i?[Sc,...i]:[Sc]),[i]),w=d((()=>l.map((e=>e.getPlugin))),[l]),[x,k]=f((()=>{o.id||(o.id=n||Z()),o.applyChanges=m,o.readOnly=g||!1,b&&(o.formats=lc(o,b)),o.blocks=function(e,t){const n={};return t.forEach((t=>{var o;const r=ri(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=di(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=L(e,{at:e.selection});return(null==n?void 0:n.type)===t.type},toggle:n=>rc(e,t.type,n),create:n=>Ql(e,t.type,n),update:(t,n)=>{nc(e,t,n)},delete:t=>{ic(e,t)}}}})),n}(o,w);const e=function(e){return!!e&&"object"==typeof e&&0!==Object.keys(e).length}(r);return e||void 0===r||console.error(`Initial value is not valid. Should be an object with blocks. You passed: ${JSON.stringify(r)}`),o.children=e?r:Dc,o.blockEditorsMap=cc(o),o.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}(o),o.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}(w),o.on=Bc,o.once=Rc,o.off=_c,o.emit=Ac,{editor:o,version:0}}));return(e=>!!(Array.isArray(e)&&e.length>0)&&e.some((e=>{if(e.id||e.nodeType||e.type||e.children)return!0})))(r)?(console.error("Legacy version of Yoopta-Editor in use"),t("div",{children:[e("h1",{children:"Legacy version of the Yoopta-Editor is used"}),e("p",{children:"It looks like you are using a legacy version of the editor."}),t("p",{children:["The structure of value has changed in new ",e("b",{children:"@v4"})," version"]}),t("p",{children:["Please, check the migration guide to update your editor to the new ",e("b",{children:"@v4"})," version.",e("a",{href:""})]}),t("p",{children:["If you have specific case please"," ",e("a",Object.assign({href:"https://github.com/Darginec05/Yoopta-Editor/issues",target:"_blank",rel:"noopener noreferrer"},{children:"open the issue"}))," ","and we will solve your problem with migration"]})]})):e(Oc,{children:e(z,Object.assign({editorState:x},{children:e(ci,Object.assign({tools:s},{children:e(Ec,Object.assign({placeholder:h,marks:b,autoFocus:c,className:a,selectionBoxRoot:u,width:v,style:y},{children:p}))}))}))})},Tc=Object.assign(Object.assign({},yi),{ExtendedBlockActions:({id:o,className:r,style:i,onClick:l,children:c})=>{const a=V(),[s,d]=f(!1),{refs:u,floatingStyles:p,context:h}=Pr({placement:"bottom-start",open:s,onOpenChange:d,middleware:[Ho(),Fo(),zo(),ko(10)],whileElementsMounted:Io}),{isMounted:g,styles:v}=Hr(h,{duration:100}),y=Object.assign(Object.assign({},v),p);return a?null:t(n,{children:[g&&e(vi,Object.assign({isOpen:!0,onClose:()=>d(!1),refs:u,style:y},{children:c})),e("button",Object.assign({type:"button",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(qr,{})}))]})},Portal:fi,Overlay:ui});function Nc(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 Lc(e){return Array.from(new Set(e))}function Pc(e,t){try{w.blur(t),w.deselect(t),D.deselect(t)}catch(e){}e.setBlockSelected(null),e.setSelection(null)}const Ic={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 zc(e,t){return e.map((e=>{var n,o;let r="";if(e.text)return r=Object.keys(Ic).reduce(((t,n)=>e[n]?`<${Ic[n].tag}>${t}</${Ic[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,zc(e.children,t)),r}return r})).join("")}function Fc(e,t){const n=Object.values(t).filter((t=>{var n;return 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=zc(t.value[0].children,e.plugins);return r.parsers.html.serialize(t.value[0],n)}return""}));return`<body id="yoopta-clipboard" data-editor-id="${e.id}">${n.join("")}</body>`}const Hc=()=>{const e={id:"",children:{},selection:null,selectedBlocks:null,readOnly:!1,getEditorValue:()=>function(e){return e.applyChanges(),e.children}(e),setEditorValue:(...t)=>function(e,t){e.children=t,e.blockEditorsMap=cc(e),e.applyChanges(),e.emit("change",e.children)}(e,...t),applyChanges:()=>{},insertBlock:(...t)=>sc(e,...t),insertBlocks:(...t)=>bc(e,...t),deleteBlocks:(...t)=>dc(e,...t),deleteBlock:(...t)=>ic(e,...t),duplicateBlock:(...t)=>mc(e,...t),toggleBlock:(...t)=>rc(e,...t),increaseBlockDepth:(...t)=>hc(e,...t),decreaseBlockDepth:(...t)=>gc(e,...t),moveBlock:(...t)=>uc(e,...t),focusBlock:(...t)=>fc(e,...t),getBlock:(...t)=>wc(e,...t),updateBlock:(...t)=>nc(e,...t),splitBlock:(...t)=>pc(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=Lc(t)}else e.selectedBlocks=Lc(i.concat(t));e.applyChanges()}(e,...t),blockEditorsMap:{},blocks:{},formats:{},shortcuts:{},plugins:{},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=L(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:Nn(e);if(!o)return;const{waitExecution:r,waitExecutionMs:i}=t;r?setTimeout((()=>Pc(e,o)),i):(Hi.set(e,!1),Pc(e,o),e.emit("blur",!1),e.applyChanges())}(e,...t),getHTML:t=>Fc(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=Fc(e,t),o=document.createElement("div");return o.innerHTML=n,o.innerText}(e,t)};return e};function Uc(e,t,n){const o=e.children[t];if(!o)throw new Error(`Block with id ${t} not found`);const r=Nn(e,{at:[o.meta.order]});if(!r)return void console.warn("No slate found");let i=e=>_.isElement(e);(null==n?void 0:n.type)&&(i=e=>_.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 Vc(e,t,n){const o=Uc(e,t,n);if(o)return o[0]}const $c={createElement:function(e,t,n,o){const r=e.children[t];if(!r)throw new Error(`Block with id ${t} not found`);const i=Nn(e,{at:[r.meta.order]});i?S.withoutNormalizing(i,(()=>{const l=e.blocks[r.type],c=l.elements[n.type],a=G({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(G({type:e,props:t.props}))}))})),d.length>0&&(a.children=d);const{path:u,focus:f=!0}=o||{};let p;const h=Uc(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=Uc(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=Nn(e,{at:[o.meta.order]});r?S.withoutNormalizing(r,(()=>{D.removeNodes(r,{at:n.path,match:e=>_.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=Nn(e,{at:[r.meta.order]});i?S.withoutNormalizing(i,(()=>{const[t]=S.nodes(i,{at:(null==o?void 0:o.path)||[0],match:e=>_.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=>_.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]:L(e);if(!i)return void console.warn(`To set text programmatically, you must provide a valid blockId. Got: ${o}`);const l=Nn(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:Vc,getElementChildren:function(e,t,n){const o=Vc(e,t,n);if(o)return o.children},getElementEntry:Uc,isElementEmpty:function(e,t,n){const o=e.children[t];if(!o)throw new Error(`Block with id ${t} not found`);const r=Nn(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=>_.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=Nn(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=Nn(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}*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}button{background-color:transparent;border:none;cursor:pointer}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}::-moz-selection{background:#c6ddf8}::selection{background:#c6ddf8}.yoopta-editor{height:auto}.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{xc as Blocks,$c as Elements,Li as HOTKEYS,Tc as UI,N as YooptaPlugin,J as buildBlockData,G as buildBlockElement,Hc as createYooptaEditor,Cc as createYooptaMark,Mc as default,L as findPluginBlockBySelectionPath,Nc as findPluginBlockByType,Nn as findSlateBySelectionPath,Z as generateId,ri as getRootBlockElement,oi as getRootBlockElementType,H as useBlockData,W as useBlockSelected,F as useYooptaEditor,U as useYooptaFocused,$ as useYooptaPluginOptions,V as useYooptaReadOnly,ai as useYooptaTools};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yoopta/editor",
|
|
3
|
-
"version": "4.6.5
|
|
3
|
+
"version": "4.6.5",
|
|
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": "
|
|
70
|
+
"gitHead": "1eedd618c0410c302cb0d589d9ddec7216c4c44a"
|
|
71
71
|
}
|