@yoopta/editor 1.9.21-rc → 1.9.23-rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,7 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
- import { YooptaBaseElement } from '../../types';
3
- import { ParentYooptaPlugin, YooptaPluginType } from '../../utils/plugins';
2
+ import { YooptaBaseElement, YooptaTools } from '../../types';
3
+ import { YooptaPluginType } from '../../utils/plugins';
4
4
  import { YooptaMark } from '../../utils/marks';
5
- import { YooptaTools } from '../../components/YooptaEditor/YooptaEditor';
6
5
  export type HoveredElement = YooptaBaseElement<string> | null;
7
6
  type YooptaToolsMap = {
8
7
  Toolbar: (props: any) => ReactElement;
@@ -20,7 +19,7 @@ export type YooptaContextHandlers = {};
20
19
  export type YooptaContextType = YooptaContextReturnValues;
21
20
  type Props = {
22
21
  children: ReactNode;
23
- plugins: ParentYooptaPlugin[];
22
+ plugins: Omit<YooptaPluginType, 'childPlugin'>[];
24
23
  marks?: YooptaMark[];
25
24
  tools?: YooptaTools | undefined;
26
25
  };
package/dist/index.js CHANGED
@@ -10,4 +10,4 @@ import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import
10
10
  Licensed under the MIT License (MIT), see
11
11
  http://jedwatson.github.io/classnames
12
12
  */
13
- st={get exports(){return lt},set exports(e){lt=e}},function(){var e={}.hasOwnProperty;function t(){for(var n=[],r=0;r<arguments.length;r++){var o=arguments[r];if(o){var i=typeof o;if("string"===i||"number"===i)n.push(o);else if(Array.isArray(o)){if(o.length){var a=t.apply(null,o);a&&n.push(a)}}else if("object"===i){if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]")){n.push(o.toString());continue}for(var s in o)e.call(o,s)&&o[s]&&n.push(s)}}}return n.join(" ")}st.exports?(t.default=t,st.exports=t):window.classNames=t}();var ct=lt;function dt(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}var ut="u-OdDyDx",ft="xA0VqV0c";dt(".u-OdDyDx:after{color:#aaa;content:attr(data-placeholder);font-size:75%;font-style:inherit;font-weight:inherit;padding-left:5px;position:absolute;text-indent:2px;top:50%;transform:translateY(-50%);user-select:none}.xA0VqV0c{background-color:#accef7}");const pt={margin:"1px 0",whiteSpace:"pre-wrap",wordBreak:"break-word",color:"inherit",fontSize:"inherit",lineHeight:"inherit",fontWeight:"inherit"},ht=l((({attributes:t,children:n,placeholder:r,leaf:o})=>{const i=O();return e("span",Object.assign({},t,{"data-placeholder":r,style:pt,className:ct({[ut]:o.withPlaceholder&&r&&i,[ft]:o.selection})},{children:n}))}));ht.displayName="TextLeaf";var gt;function vt(){return vt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},vt.apply(this,arguments)}var yt,mt=function(e){return n.createElement("svg",vt({viewBox:"0 0 10 10",fill:"currentColor",style:{width:14,height:14,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),gt||(gt=n.createElement("path",{d:"M3 2a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm4-8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"})))};function bt(){return bt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bt.apply(this,arguments)}var wt=function(e){return n.createElement("svg",bt({viewBox:"0 0 16 16",fill:"currentColor",style:{width:16,height:16,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),yt||(yt=n.createElement("path",{d:"M7.977 14.963c.407 0 .747-.324.747-.723V8.72h5.362c.399 0 .74-.34.74-.747a.746.746 0 0 0-.74-.738H8.724V1.706c0-.398-.34-.722-.747-.722a.732.732 0 0 0-.739.722v5.529h-5.37a.746.746 0 0 0-.74.738c0 .407.341.747.74.747h5.37v5.52c0 .399.332.723.739.723z"})))},_t="QEROK9NJ",Ot="ZLDKsGEc",xt="_0wBAdXIb",Et="P40m4iJS",jt="_7iHqOybQ";dt(".QEROK9NJ{inset:0;overflow:hidden;pointer-events:none;position:fixed;z-index:999}.ZLDKsGEc,._0wBAdXIb{position:relative;z-index:0}._0wBAdXIb{pointer-events:auto}.P40m4iJS{height:100vh;left:0;position:fixed;top:0;width:100vw}._7iHqOybQ{pointer-events:auto;position:relative;top:100%}");const kt=({children:n,onClose:r})=>{const[a]=o((()=>document.createElement("div")));return i((()=>(a.className="yoopta-overlay",document.body.appendChild(a),()=>{document.body.removeChild(a)})),[a]),N(t("div",Object.assign({className:_t},{children:[e("div",{className:Ot}),t("div",Object.assign({className:xt},{children:[e("div",{className:Et,onClick:r}),e("div",Object.assign({className:jt,onClick:e=>e.stopPropagation()},{children:n}))]}))]})),a)};var Nt;function St(){return St=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},St.apply(this,arguments)}var Pt,Dt=function(e){return n.createElement("svg",St({viewBox:"0 0 16 16",className:"trash_svg__trash",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Nt||(Nt=n.createElement("path",{d:"M4.862 15.429h6.283c1.045 0 1.722-.636 1.77-1.689l.465-9.85h.752c.342 0 .608-.26.608-.602a.594.594 0 0 0-.608-.595H11.09V1.668C11.09.622 10.427 0 9.292 0H6.694C5.566 0 4.896.622 4.896 1.668v1.025H1.861a.598.598 0 1 0 0 1.196h.76l.464 9.858c.048 1.053.718 1.682 1.777 1.682Zm1.292-13.7c0-.355.246-.58.63-.58h2.42c.382 0 .628.225.628.58v.964H6.154V1.73ZM4.992 14.22c-.376 0-.65-.274-.67-.677L3.864 3.89h8.251l-.444 9.652c-.014.403-.287.677-.677.677H4.992Zm.991-1.1c.288 0 .472-.185.465-.452l-.205-7.164c-.007-.274-.198-.451-.472-.451-.287 0-.471.184-.464.45l.205 7.165c.007.273.198.451.471.451Zm2.017 0c.287 0 .479-.185.479-.452V5.503c0-.267-.192-.451-.479-.451s-.479.184-.479.45v7.165c0 .267.192.451.479.451Zm2.017 0c.273 0 .458-.179.464-.452l.212-7.164c.007-.267-.184-.451-.464-.451-.274 0-.465.177-.472.45l-.212 7.165c-.007.267.184.451.472.451Z"})))};function At(){return At=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},At.apply(this,arguments)}var Ct,Tt=function(e){return n.createElement("svg",At({viewBox:"0 0 16 16",className:"duplicate_svg__duplicate",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Pt||(Pt=n.createElement("path",{d:"M2.839 12.152H4v1.033c0 1.456.759 2.214 2.242 2.214h6.918c1.477 0 2.242-.758 2.242-2.214V6.212c0-1.456-.765-2.215-2.242-2.215H12V2.965c0-1.456-.766-2.215-2.242-2.215H2.839C1.362.75.597 1.502.597 2.965V9.93c0 1.463.765 2.221 2.242 2.221Zm.082-1.34c-.636 0-.984-.328-.984-.99v-6.74c0-.664.348-.999.984-.999h6.76c.63 0 .985.335.985.998v.916H6.243c-1.483 0-2.242.759-2.242 2.215v4.6h-1.08Zm3.397 3.248c-.635 0-.977-.329-.977-.992v-6.74c0-.663.342-.991.977-.991h6.761c.629 0 .984.328.984.991v6.74c0 .663-.355.992-.984.992H6.32Z"})))};function Lt(){return Lt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Lt.apply(this,arguments)}var Mt,Bt=function(e){return n.createElement("svg",Lt({viewBox:"0 0 16 16",className:"turn_svg__loop",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Ct||(Ct=n.createElement("path",{d:"M5.804 3.123c.006.38.254.622.673.622h4.887c.59 0 .914.305.914.92v6.628l-.901-.978-.514-.514c-.267-.254-.629-.273-.895-.013-.254.26-.248.635.012.895l2.165 2.158c.476.47 1.022.47 1.498 0l2.165-2.158c.26-.26.266-.635.012-.895-.266-.26-.628-.241-.895.013l-.514.514-.895.971V4.564c0-1.358-.71-2.063-2.082-2.063H6.477c-.42 0-.68.241-.673.622ZM.186 7.06c.26.266.622.247.889-.013l.52-.508.889-.971v6.722c0 1.359.71 2.063 2.082 2.063h4.957c.42 0 .68-.241.673-.622-.006-.387-.254-.622-.673-.622h-4.88c-.591 0-.915-.311-.915-.927V5.554l.895.984.52.508c.26.26.629.28.89.013.26-.26.253-.629-.013-.89L3.855 4.013c-.476-.476-1.016-.476-1.492 0L.2 6.17c-.267.26-.273.628-.013.889Z"})))};function Ft(){return Ft=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ft.apply(this,arguments)}var zt=function(e){return n.createElement("svg",Ft({viewBox:"0 0 16 16",className:"copy_svg__link",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Mt||(Mt=n.createElement("path",{d:"m7.7 10.895 1.038-1.046c-.82-.076-1.394-.335-1.818-.76-1.155-1.154-1.155-2.795-.007-3.943l2.27-2.27c1.155-1.155 2.789-1.155 3.944 0 1.162 1.169 1.155 2.796.007 3.944l-1.176 1.176a2.74 2.74 0 0 1 .17 1.634l1.963-1.955c1.682-1.675 1.688-4.054-.007-5.75C12.389.225 10.01.238 8.335 1.913L5.956 4.298c-1.675 1.675-1.688 4.054.007 5.749.403.396.943.697 1.736.848Zm.6-5.763L7.27 6.178c.813.075 1.394.342 1.811.759 1.162 1.162 1.162 2.795.007 3.944l-2.27 2.27c-1.155 1.155-2.782 1.155-3.944 0-1.162-1.163-1.155-2.796 0-3.945L4.042 8.03a2.788 2.788 0 0 1-.17-1.634L1.915 8.352c-1.682 1.674-1.688 4.06.007 5.755 1.695 1.696 4.074 1.682 5.749.007l2.372-2.379c1.682-1.681 1.688-4.06-.007-5.749-.396-.403-.936-.704-1.736-.854Z"})))};const Ht=r.createContext({marks:{},elements:{}}),Rt=({children:t,plugins:n,marks:o,tools:i})=>{const a=_(),l=c(),d=e=>{if(!a.selection)return!1;const[t]=u.nodes(a,{at:u.unhangRange(a,a.selection),match:t=>!u.isEditor(t)&&g.isElement(t)&&t.type===e,mode:"highest"});return!!t},f=()=>{const e={};return n.forEach((t=>{const{createElement:n,defineElement:r,type:o,options:i}=t;H(t,["createElement","defineElement","type","options"]),e[t.type]={create:n,define:r,toggle:e=>((e,t)=>{u.withoutNormalizing(a,(()=>{var n;if(!a.selection)return;const{offset:r,path:o}=a.selection.anchor,{shouldDeleteText:i}=t||{};i&&h.delete(a,{at:{anchor:{path:o,offset:0},focus:{path:o,offset:r}}});const s=u.above(a,{at:a.selection,mode:"highest",match:e=>!u.isEditor(e)&&g.isElement(e)}),[l,c]=u.parent(a,p.parent(a.selection.anchor.path)),[d]=s||[];(null==d?void 0:d.type)!==e.type?(g.isElement(l)&&!u.isEditor(l)&&h.unwrapNodes(a,{at:c,match:e=>!u.isEditor(e)&&!v.isText(e)&&g.isElement(l)&&e.type===l.type}),null===(n=e.createElement)||void 0===n||n.call(e,a,{id:d.id})):h.setNodes(a,tt(Te()),{mode:"highest",match:e=>!u.isEditor(e)&&g.isElement(e)})}))})(t,e),type:o,isActive:d(o),options:{displayLabel:null==i?void 0:i.displayLabel}}})),e},y=s((()=>f()),[n,a.selection]),m=e=>{const t=u.marks(a);return!!(null==t?void 0:t[e])},b=s((()=>{const e={};return null==o||o.forEach((t=>{e[t.type]={toggle:e=>((e,t=!1)=>{t&&Object.keys(u.marks(a)||{}).forEach((e=>{u.removeMark(a,e)})),m(e)?u.removeMark(a,e):u.addMark(a,e,!0)})(t.type,null==e?void 0:e.only),isActive:m(t.type)}})),e}),[o,a.selection]),w=s((()=>{const e=Object.keys(i||{});if(0===e.length)return;const t={};return e.forEach((e=>{const o=null==i?void 0:i[e];o&&r.isValidElement(o)&&(t[e]=e=>{var{style:t,className:i}=e,a=H(e,["style","className"]);return r.cloneElement(o,Object.assign(Object.assign({style:t,className:i,plugins:n,fromHook:!0},null==o?void 0:o.props),a))})})),t}),[i]);return l.current={elements:y,marks:b,tools:w},e(Ht.Provider,Object.assign({value:l.current},{children:t}))},It=()=>a(Ht),Vt=()=>a(Ht).marks,Wt=()=>a(Ht).elements,Ut=()=>a(Ht).tools;var Zt="IMJgzRnZ",$t="nFfAiJWo",qt="DeARgIyF",Kt="kyuzONcU",Gt="_95up7F66",Jt="_9d0T-cEo";dt(".IMJgzRnZ{align-items:center;background:#fff;border-radius:4px;box-shadow:0 0 0 1px hsla(0,0%,6%,.05),0 3px 6px hsla(0,0%,6%,.1),0 9px 24px hsla(0,0%,6%,.2);display:flex;flex-direction:column;height:auto;max-height:70vh;max-width:calc(100vw - 24px);min-width:200px;opacity:1;overflow:hidden;position:fixed;transform-origin:0 top;width:auto}.nFfAiJWo{flex-grow:1;margin-bottom:0;margin-right:0;min-height:0;overflow:hidden auto;position:relative;transform:translateZ(0);width:100%;z-index:1}.DeARgIyF{box-shadow:0 -1px 0 rgba(55,53,47,.09);padding-bottom:6px;padding-top:6px}.kyuzONcU{align-items:center;background:inherit;border:none;border-radius:3px;color:#000;cursor:pointer;display:flex;font-size:14px;line-height:120%;margin-left:4px;margin-right:4px;min-height:28px;transition:background 20ms ease-in 0s;user-select:none;width:calc(100% - 8px)}.kyuzONcU:hover{background-color:rgba(55,53,47,.08);color:#000}._95up7F66{align-items:center;color:#000;display:flex;justify-content:center;margin-left:10px;margin-right:4px}._9d0T-cEo{flex:1 1 auto;margin-left:6px;margin-right:6px;overflow:hidden;text-align:left;text-overflow:ellipsis}._5FdNFUNm,._9d0T-cEo{min-width:0;white-space:nowrap}._5FdNFUNm{color:rgba(55,53,47,.5);flex-shrink:0;font-size:12px;margin-left:auto;margin-right:12px}");const Xt={position:"fixed",opacity:1,bottom:"auto",right:"auto"},Qt=n=>{var{onClose:r,style:i,element:a,render:s}=n,l=H(n,["onClose","style","element","render"]);const[d,f]=o({style:Xt,open:!1}),p=c(null),h=_(),g=Ut(),[,v]=at(),{ActionMenu:y}=g||{},m=!!y,b=u.isVoid(h,a),w=()=>f({style:Xt,open:!1});return e(kt,Object.assign({onClose:r},{children:e("div",Object.assign({style:i,className:ct(Zt,"yoopta-element-options"),ref:p},{children:t("div",Object.assign({className:$t},{children:[d.open&&y&&e(kt,Object.assign({onClose:w},{children:y&&e(y,{style:d.style,options:{shouldDeleteText:!1},on:{toggle:()=>{w(),v.closeNodeSettings()}}})})),t("div",Object.assign({className:qt},{children:[t("button",Object.assign({type:"button",className:Kt,onClick:()=>{var e;v.deleteNode(),null===(e=l.onDelete)||void 0===e||e.call(l)}},{children:[e("div",Object.assign({className:Gt},{children:e(Dt,{})})),e("div",Object.assign({className:Jt},{children:"Delete"}))]})),t("button",Object.assign({type:"button",className:Kt,onClick:()=>{var e;v.duplicateNode(),null===(e=l.onDuplicate)||void 0===e||e.call(l)}},{children:[e("div",Object.assign({className:Gt},{children:e(Tt,{})})),e("div",Object.assign({className:Jt},{children:"Duplicate"}))]})),!b&&m&&t("button",Object.assign({type:"button",className:Kt,onClick:e=>{var t;const n=p.current.getBoundingClientRect(),r=null===(t=document.querySelector(".yoopta-action-menu-list"))||void 0===t?void 0:t.getBoundingClientRect(),o={left:n.left+n.width+10,top:n.top+n.height};r&&o.left+r.width>window.innerWidth&&(o.left=n.left-r.width-10),r&&o.top<r.height&&(o.top=r.height+20),f((e=>({open:!e.open,style:Object.assign(Object.assign({},e.style),o)})))}},{children:[e("div",Object.assign({className:Gt},{children:e(Bt,{})})),e("div",Object.assign({className:Jt},{children:"Turn into"}))]})),t("button",Object.assign({type:"button",className:Kt,onClick:()=>{var e;v.copyLinkNode(),null===(e=l.onCopy)||void 0===e||e.call(l)}},{children:[e("div",Object.assign({className:Gt},{children:e(zt,{})})),e("div",Object.assign({className:Jt},{children:"Copy link to block"}))]}))]}))]}))}))}))};var Yt="yCQ-VdE5",en="b--398nS",tn="_6VhqH6wy",nn="k9i48GWd",rn="TNeDy6y5",on="jVfkavqE",an="_87oFW01f",sn="oz5S7EmO";dt('.yCQ-VdE5{display:flex;left:-50px;opacity:0;position:absolute;top:2px;transition:opacity .18s ease-in}.b--398nS{opacity:1}._6VhqH6wy{all:unset;align-items:center;background-color:inherit;background-color:transparent;border-radius:6px;color:rgba(55,53,47,.35);cursor:pointer;display:flex;height:24px;justify-content:center;margin:0 1px;padding:0;position:relative;transition:background-color .18s cubic-bezier(.4,0,.2,1);width:auto;width:18px}._6VhqH6wy:active,._6VhqH6wy:focus,._6VhqH6wy:hover{background-color:rgba(55,54,47,.08)}.k9i48GWd{width:24px}.TNeDy6y5{position:relative;transition:opacity .18s cubic-bezier(.4,0,.2,1)}.jVfkavqE:after{background-color:#007aff;bottom:-7px;content:"";height:3px;left:50%;position:absolute;transform:translateX(-50%);width:100%}._87oFW01f:before{top:-5px}._87oFW01f:after,._87oFW01f:before{background-color:inherit;content:"";height:3px;left:50%;position:absolute;transform:translateX(-50%);width:100%}._87oFW01f:after{bottom:-7px}.oz5S7EmO{background:rgba(35,131,226,.14);border-radius:3px;inset:0;opacity:1;pointer-events:none;position:absolute;transition:background-color .18s cubic-bezier(.4,0,.2,1);z-index:81}');const ln=({element:n,editor:r,values:o,handlers:i})=>{const a=c(null),{hoveredElement:s,isElementOptionsOpen:l,nodeSettingsPos:d}=o,{onDragEnd:f,onDragStart:p,openNodeSettings:h,closeNodeSettings:v,triggerPlusButton:y}=i,m=e=>{e.stopPropagation();const t=a.current,o=document.querySelector(`[data-element-id="${null==n?void 0:n.id}"]`),i=w.findPath(r,n),s=u.parent(r,i);g.isElement(n)&&(null==t||t.setAttribute("draggable","false"),o&&(o.setAttribute("draggable","true"),o.ondragstart=e=>{const t={path:i,element:{id:n.id,type:n.type},parent:s};p(e,t)},o.ondragend=f))},b=(null==s?void 0:s.id)===n.id;return t("div",Object.assign({contentEditable:!1,className:ct(Yt,{[en]:b},"yoopta-element-actions")},{children:[b&&l&&e(Qt,{element:n,style:d||void 0,onClose:v}),e("button",Object.assign({type:"button",onMouseDown:m,className:ct(tn,nn,"yoopta-element-actions-plus"),onClick:()=>y(n)},{children:e(wt,{})})),e("button",Object.assign({type:"button",onMouseDown:m,className:ct(tn,"yoopta-element-actions-drag"),onClick:()=>h(a,n),ref:a},{children:e(mt,{})}))]}))},cn=({children:n,element:r,attributes:o,nodeType:i,render:a,HTMLAttributes:l})=>{var c,d;const u=_(),[f,p]=at(),h="inline"===i,{hoverIn:g,onDrop:v}=p,{dndState:y,DRAG_MAP:m}=f,b=s((()=>{var e,t;if(null===y.from.element||null===y.to.element)return{isDragging:!1,isDragOver:!1,isDragSelf:!1};const n=(null===(e=f.dndState.from.element)||void 0===e?void 0:e.id)===r.id,o=(null===(t=f.dndState.to.element)||void 0===t?void 0:t.id)===r.id;return{isDragging:n,isDragOver:o,isDragSelf:n&&o}}),[f.dndState.from,f.dndState.to]),w=null===(c=r.data)||void 0===c?void 0:c.skipSettings,{isDragging:O,isDragOver:x,isDragSelf:E}=b,j={opacity:O?.7:1};return m.set(r.id,r),h?a({attributes:o,element:r,children:n,HTMLAttributes:l}):t("div",Object.assign({"data-element-id":r.id,"data-element-type":r.type,onMouseEnter:e=>{w||g(e,r)},onDrop:v,className:ct(rn,{[on]:x,[an]:E}),style:j},o,{children:[w?null:e(ln,{editor:u,element:r,handlers:p,values:f}),a({attributes:o,element:r,children:n,HTMLAttributes:l}),(null===(d=f.selectedNodeElement)||void 0===d?void 0:d.id)===r.id&&e("div",{className:ct(sn,"yoopta-selected-node-element")})]}))};cn.displayName="ElementWrapper";var dn={};Object.defineProperty(dn,"__esModule",{value:!0});for(var un="undefined"!=typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),fn={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},pn={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:un?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},hn={backspace:8,tab:9,enter:13,shift:16,control:17,alt:18,pause:19,capslock:20,escape:27," ":32,pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,insert:45,delete:46,meta:91,numlock:144,scrolllock:145,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},gn=1;gn<20;gn++)hn["f"+gn]=111+gn;function vn(e,t,n){t&&!("byKey"in t)&&(n=t,t=null),Array.isArray(e)||(e=[e]);var r=e.map((function(e){return yn(e,t)})),o=function(e){return r.some((function(t){return mn(t,e)}))};return null==n?o:o(n)}function yn(e,t){var n=t&&t.byKey,r={},o=(e=e.replace("++","+add")).split("+"),i=o.length;for(var a in fn)r[fn[a]]=!1;var s=!0,l=!1,c=void 0;try{for(var d,u=o[Symbol.iterator]();!(s=(d=u.next()).done);s=!0){var f=d.value,p=f.endsWith("?")&&f.length>1;p&&(f=f.slice(0,-1));var h=wn(f),g=fn[h];if(f.length>1&&!g&&!pn[f]&&!hn[h])throw new TypeError('Unknown modifier: "'+f+'"');1!==i&&g||(n?r.key=h:r.which=bn(f)),g&&(r[g]=!p||null)}}catch(e){l=!0,c=e}finally{try{!s&&u.return&&u.return()}finally{if(l)throw c}}return r}function mn(e,t){for(var n in e){var r=e[n],o=void 0;if(null!=r&&((null!=(o="key"===n&&null!=t.key?t.key.toLowerCase():"which"===n?91===r&&93===t.which?91:t.which:t[n])||!1!==r)&&o!==r))return!1}return!0}function bn(e){return e=wn(e),hn[e]||e.toUpperCase().charCodeAt(0)}function wn(e){return e=e.toLowerCase(),e=pn[e]||e}dn.default=vn;var _n=dn.isHotkey=vn,On=dn.isCodeHotkey=function(e,t){return vn(e,t)},xn=dn.isKeyHotkey=function(e,t){return vn(e,{byKey:!0},t)};dn.parseHotkey=yn,dn.compareHotkey=mn,dn.toKeyCode=bn,dn.toKeyName=wn;const En={bold:"mod+b",italic:"mod+i",compose:["down","left","right","up","backspace","enter"],arrowLeft:"left",arrowUp:"up",arrowDown:"down",arrowRight:"right",ctrlLeft:"ctrl+left",escape:"esc",ctrlRight:"ctrl+right",deleteBackward:"shift?+backspace",backspace:"backspace",deleteForward:"shift?+delete",extendBackward:"shift+left",extendForward:"shift+right",shiftEnter:"shift+enter",enter:"enter",space:"space",undo:"mod+z",select:"mod+a",shiftTab:"shift+tab",tab:"tab",cmd:"mod",cmdEnter:"mod+enter",kekCeburek:"mod+enter"},jn={moveLineBackward:"opt+up",moveLineForward:"opt+down",ctrlLeft:"opt+left",ctrlRight:"opt+right",deleteBackward:["ctrl+backspace","ctrl+h"],deleteForward:["ctrl+delete","ctrl+d"],deleteLineBackward:"cmd+shift?+backspace",deleteLineForward:["cmd+shift?+delete","ctrl+k"],deleteWordBackward:"opt+shift?+backspace",deleteWordForward:"opt+shift?+delete",extendLineBackward:"opt+shift+up",extendLineForward:"opt+shift+down",redo:"cmd+shift+z",transposeCharacter:"ctrl+t"},kn={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},Nn=e=>{const t=En[e],n=jn[e],r=kn[e],o=t&&xn(t),i=n&&xn(n),a=r&&xn(r);return e=>!(!o||!o(e))||(!(!i||!i(e))||!(!a||!a(e)))},Sn={isBold:Nn("bold"),isCompose:Nn("compose"),isArrowLeft:Nn("arrowLeft"),isArrowRight:Nn("arrowRight"),isArrowUp:Nn("arrowUp"),isArrowDown:Nn("arrowDown"),isDeleteBackward:Nn("deleteBackward"),isDeleteForward:Nn("deleteForward"),isDeleteLineBackward:Nn("deleteLineBackward"),isDeleteLineForward:Nn("deleteLineForward"),isDeleteWordBackward:Nn("deleteWordBackward"),isDeleteWordForward:Nn("deleteWordForward"),isExtendBackward:Nn("extendBackward"),isExtendForward:Nn("extendForward"),isExtendLineBackward:Nn("extendLineBackward"),isExtendLineForward:Nn("extendLineForward"),isItalic:Nn("italic"),isMoveLineBackward:Nn("moveLineBackward"),isMoveLineForward:Nn("moveLineForward"),isCtrlLeft:Nn("ctrlLeft"),isCtrlRight:Nn("ctrlRight"),isRedo:Nn("redo"),isShiftEnter:Nn("shiftEnter"),isEnter:Nn("enter"),isTransposeCharacter:Nn("transposeCharacter"),isUndo:Nn("undo"),isSpace:Nn("space"),isSelect:Nn("select"),isTab:Nn("tab"),isShiftTab:Nn("shiftTab"),isBackspace:Nn("backspace"),isCmdEnter:Nn("cmdEnter"),isCmd:Nn("cmd"),isEscape:Nn("escape"),isKekceburek:Nn("kekCeburek")},Pn=(e,t)=>!!((e,t)=>{const{selection:n}=e;if(!n)return!1;const[r]=Array.from(u.nodes(e,{at:u.unhangRange(e,n),match:e=>!u.isEditor(e)&&g.isElement(e)&&e.type===t}));return r})(e,t),Dn=(e,t,n="lowest")=>{var r;const o=Array.from(u.nodes(e,{match:t=>u.isEditor(e)&&g.isElement(t),at:t||(null===(r=e.selection)||void 0===r?void 0:r.anchor.path),mode:n}))[0];return o?o[0]:e.children[0]};function An(e,t){var n,r;if(v.isText(e))return function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return e.replace(/[&<>"']/g,(e=>t[e]))}(e.text);const o=e.children.map((e=>An(e,t))).join(""),i=t[e.type];return"function"==typeof(null===(r=null===(n=i.exports)||void 0===n?void 0:n.html)||void 0===r?void 0:r.serialize)?i.exports.html.serialize(e,o):o}function Cn(e,t){return e.map((e=>An(e,t))).join("")}const Tn={outline:"none"},Ln={hotkeys:Sn,defaultNode:tt(Te())},Mn=({editor:n,placeholder:r,marks:o,readOnly:a,plugins:l,className:f,PLUGINS_MAP:v})=>{i((()=>{const e=window.location.hash.length>0?window.location.hash.replace("#",""):null;if(e){const t=document.getElementById(e)||document.querySelector(`[data-element-id="${e}"]`);t&&window.scrollTo({top:t.offsetTop,behavior:"smooth"})}}),[]);const m=c(null),[{disableWhileDrag:b},{changeHoveredNode:_}]=at(),O=Ut(),{ActionMenu:E,Toolbar:j}=O||{},k=b||a,N=s((()=>t=>{var r;const o=v[t.element.type];if(!o)return null;const i=function(e){return"function"==typeof e.renderer?e.renderer:e.renderer.editor}(o)(n,o);return e(cn,Object.assign({element:t.element,attributes:t.attributes,nodeType:t.element.nodeType,render:i,HTMLAttributes:null===(r=o.options)||void 0===r?void 0:r.HTMLAttributes},{children:t.children}))}),[l,n]),S=s((()=>e=>{const t=[],[r,o]=e;return l.forEach((o=>{const i=o.decorator;"function"==typeof i&&g.isElement(r)&&r.type===o.type&&t.push(...i(n)(e))})),n.selection&&!u.isEditor(r)&&""===u.string(n,[o[0]])&&y.includes(n.selection,o)&&y.isCollapsed(n.selection)&&t.push(Object.assign(Object.assign({},n.selection),{withPlaceholder:!0})),t}),[l,n]),P=s((()=>t=>{var i;const a=Object.assign({},t);let s;l.forEach((e=>{if(e.leaf){const t=e.leaf(n)(a);t&&(a.children=t)}})),null==o||o.forEach((e=>{a.leaf[e.type]&&(a.children=e.render(a))}));const c=null===(i=a.children.props)||void 0===i?void 0:i.parent;if(!function(e){var t,n;return 1!==(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)||0!==(null===(n=null==e?void 0:e.children[0])||void 0===n?void 0:n.text.length)}(c)){const e=v[null==c?void 0:c.type];s=null===(null==e?void 0:e.placeholder)?null:(null==e?void 0:e.placeholder)||r}return e(ht,Object.assign({},a,{placeholder:s}))}),[l,n]),D=s((()=>{const e=l.map((e=>Object.keys(e.events||{}))).flat().filter(((e,t,n)=>n.indexOf(e)===t)),t={};return e.forEach((e=>{t[e]=function(t){l.forEach((r=>{var o;if(null===(o=r.events)||void 0===o?void 0:o[e]){r.events[e](n,Ln)(t)}}))}})),t}),[l,n]),A=d((e=>{u.withoutNormalizing(n,(()=>{var t;if(!n.selection)return;const r=tt(Te());null==o||o.forEach((t=>{t.hotkey&&xn(t.hotkey)(e)&&(e.preventDefault(),nt(n,t.type,!1))})),null===(t=D.onKeyDown)||void 0===t||t.call(D,e);const i=u.above(n,{match:e=>!u.isEditor(e),mode:"lowest"});if(Sn.isEnter(e)){if(e.isDefaultPrevented())return;e.preventDefault();const t=Object.keys(u.marks(n)||{});t.length>0&&t.forEach((e=>u.removeMark(n,e)));const o=p.parent(n.selection.anchor.path),a=u.string(n,o),s=i&&i[0].type!==r.type;if(s&&0===a.length)return void h.setNodes(n,r,{at:o});if(u.isStart(n,n.selection.anchor,n.selection.anchor.path)&&s){const[e]=i;return h.setNodes(n,r,{at:o}),h.delete(n,{unit:"block"}),h.insertNodes(n,Fe(e),{at:p.next(o)}),void h.select(n,{path:[p.next(n.selection.anchor.path)[0]+1,0],offset:0})}return h.splitNodes(n,{always:!0}),h.setNodes(n,r),void _(r)}if(Sn.isShiftEnter(e)){if(e.isDefaultPrevented())return;e.preventDefault(),n.insertText("\n")}if(Sn.isSelect(e)){if(e.isDefaultPrevented())return;e.preventDefault();const t=u.above(n,{at:n.selection.anchor.path,match:e=>!u.isEditor(e)&&g.isElement(e)});if(!t)return;const r=u.string(n,t[1]);return y.isExpanded(n.selection)||0===r.length?void h.select(n,[]):void h.select(n,t[1])}}))}),[]);return t("div",Object.assign({id:"yoopta-editor",className:f,ref:m,onMouseDown:e=>{a||(e.preventDefault(),e.currentTarget===e.target&&n.selection&&u.withoutNormalizing(n,(()=>{const e=[n.children.length-1,0],t=Dn(n,e,"highest"),r=u.string(n,e),o={anchor:{path:e,offset:0},focus:{path:e,offset:0}};if("paragraph"===t.type&&0===r.length)return h.select(n,{path:o.anchor.path,offset:0}),_(t),w.focus(n);const i=tt(Te());_(i),h.insertNodes(n,i,{at:[n.children.length],select:!0}),w.focus(n)})))}},{children:[!!E&&e(E,{}),!!j&&e(j,{}),e(x,Object.assign({id:"yoopta-contenteditable",renderLeaf:P,renderElement:N,readOnly:k,decorate:S,onCopy:e=>{if(!n.selection)return;const t=Cn(u.fragment(n,n.selection),n.plugins);return e.clipboardData.setData("text/html",t),e.clipboardData},spellCheck:!0},D,{onKeyDown:A,onMouseDown:e=>{var t;null===(t=D.onMouseDown)||void 0===t||t.call(D,e),(e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()})(e)},style:Tn}))]}))};function Bn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Fn=new WeakMap,zn=new WeakMap;class Hn{}class Rn extends Hn{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super();var{offset:t,path:n}=e;this.offset=t,this.path=n}}class In extends Hn{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super();var{offset:t,path:n}=e;this.offset=t,this.path=n}}var Vn=e=>zn.get(e);function Wn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Un(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wn(Object(n),!0).forEach((function(t){Bn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Zn=new WeakSet,$n=e=>{var t=[],n=e=>{if(null!=e){var r=t[t.length-1];if("string"==typeof e){var o={text:e};Zn.add(o),e=o}if(v.isText(e)){var i=e;v.isText(r)&&Zn.has(r)&&Zn.has(i)&&v.equals(r,i,{loose:!0})?r.text+=i.text:t.push(i)}else if(g.isElement(e))t.push(e);else{if(!(e instanceof Hn))throw new Error("Unexpected hyperscript child object: ".concat(e));var a=t[t.length-1];v.isText(a)||(n(""),a=t[t.length-1]),e instanceof Rn?((e,t)=>{var n=e.text.length;Fn.set(e,[n,t])})(a,e):e instanceof In&&((e,t)=>{var n=e.text.length;zn.set(e,[n,t])})(a,e)}}};for(var r of e.flat(1/0))n(r);return t};function qn(e,t,n){return Un(Un({},t),{},{children:$n(n)})}function Kn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Gn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Kn(Object(n),!0).forEach((function(t){Bn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Kn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Jn,Xn={anchor:function(e,t,n){return new Rn(t)},cursor:function(e,t,n){return[new Rn(t),new In(t)]},editor:(Jn=b,(e,t,n)=>{var r,o=[];for(var i of n)y.isRange(i)?r=i:o.push(i);var a,s=$n(o),l={},c=Jn();for(var[d,u]of(Object.assign(c,t),c.children=s,m.texts(c))){var f=(a=d,Fn.get(a)),p=Vn(d);if(null!=f){var[h]=f;l.anchor={path:u,offset:h}}if(null!=p){var[g]=p;l.focus={path:u,offset:g}}}if(l.anchor&&!l.focus)throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<anchor />`. For collapsed selections, use `<cursor />` instead.");if(!l.anchor&&l.focus)throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<focus />`. For collapsed selections, use `<cursor />` instead.");return null!=r?c.selection=r:y.isRange(l)&&(c.selection=l),c}),element:qn,focus:function(e,t,n){return new In(t)},fragment:function(e,t,n){return $n(n)},selection:function(e,t,n){var r=n.find((e=>e instanceof Rn)),o=n.find((e=>e instanceof In));if(!r||null==r.offset||null==r.path)throw new Error("The <selection> hyperscript tag must have an <anchor> tag as a child with `path` and `offset` attributes defined.");if(!o||null==o.offset||null==o.path)throw new Error("The <selection> hyperscript tag must have a <focus> tag as a child with `path` and `offset` attributes defined.");return Un({anchor:{offset:r.offset,path:r.path},focus:{offset:o.offset,path:o.path}},t)},text:function(e,t,n){var r=$n(n);if(r.length>1)throw new Error("The <text> hyperscript tag must only contain a single node's worth of children.");var[o]=r;if(null==o&&(o={text:""}),!v.isText(o))throw new Error("\n The <text> hyperscript tag can only contain text content as children.");return Zn.delete(o),Object.assign(o,t),o}},Qn=e=>function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];var a=e[t];if(!a)throw new Error("No hyperscript creator found for tag: <".concat(t,">"));return null==n&&(n={}),D(n)||(o=[n].concat(o),n={}),a(t,n,o=o.filter((e=>Boolean(e))).flat())},Yn=e=>{var t={},n=function(n){var r=e[n];if("object"!=typeof r)throw new Error("Properties specified for a hyperscript shorthand should be an object, but for the custom element <".concat(n,"> tag you passed: ").concat(r));t[n]=(e,t,n)=>qn(0,Gn(Gn({},r),t),n)};for(var r in e)n(r);return t},er=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{elements:t={}}=e,n=Yn(t),r=Gn(Gn(Gn({},Xn),n),e.creators);return Qn(r)}();const tr={DEL:()=>({strikethrough:!0}),EM:()=>({italic:!0}),I:()=>({italic:!0}),S:()=>({strikethrough:!0}),STRONG:()=>({bold:!0}),U:()=>({underline:!0})},nr=(e,t)=>{var n,r,o,i;if(3===e.nodeType)return e.textContent;if(1!==e.nodeType)return null;if("BR"===e.nodeName)return"\n";const{nodeName:a}=e;let s=e,l=Array.from(s.childNodes).map((e=>nr(e,t))).flat();if(0===l.length&&(l=[{text:""}]),"BODY"===e.nodeName)return er("fragment",{},l);if(t[a]){const s=t[a];if(s){let t=s.defineElement();if("function"==typeof(null===(r=null===(n=s.exports)||void 0===n?void 0:n.html.deserialize)||void 0===r?void 0:r.parse)){const n=null===(i=null===(o=s.exports)||void 0===o?void 0:o.html.deserialize)||void 0===i?void 0:i.parse(e);t=Object.assign(Object.assign({},t),{data:n})}return er("element",t,l)}}if(v.isTextList(l))return er("element",t.P.defineElement(),l);if(tr[a]){const t=tr[a](e);return l.map((e=>v.isText(e)?er("text",t,e):e))}return l};function rr(e,t){try{const n=function(e){const t={};return Object.keys(e).forEach((n=>{var r,o,i,a,s,l,c,d;const u=e[n];if(null===(o=null===(r=u.exports)||void 0===r?void 0:r.html.deserialize)||void 0===o?void 0:o.nodeName){if(Array.isArray(null===(a=null===(i=u.exports)||void 0===i?void 0:i.html.deserialize)||void 0===a?void 0:a.nodeName))return void(null===(l=null===(s=u.exports)||void 0===s?void 0:s.html.deserialize)||void 0===l||l.nodeName.forEach((e=>{t[e]=u})));t[null===(d=null===(c=u.exports)||void 0===c?void 0:c.html.deserialize)||void 0===d?void 0:d.nodeName]=u}})),t}(t),r=(new DOMParser).parseFromString(e,"text/html");return nr(r.body,n)}catch(e){return console.error(e),null}}const or=({key:t,value:n,plugins:r,marks:a,readOnly:l,onChange:c,placeholder:_,autoFocus:O=!0,offline:x,className:k,tools:N})=>{const S=function(e){return"string"==typeof e?e:"yoopta-content"}(x),[P,D]=o((()=>function(e,t,n){const r=[{id:Te(),type:"paragraph",children:[{text:""}]}],o=Le(n)?n:r;if(!t)return localStorage.removeItem(e),o;try{const t=JSON.parse(localStorage.getItem(e)||"[]");return Le(t)?t:o}catch(t){return localStorage.removeItem(e),r}}(S,x,n))),A=d((e=>{if(c(e),D(e),!x)return;if(R.operations.some((e=>"set_selection"!==e.type)))try{const t=JSON.stringify(e);localStorage.setItem(S,t)}catch(e){}}),[x]),C=s((()=>{if(!Array.isArray(r))throw new Error("Props `plugins` should be array of plugins");if(Array.isArray(r)&&0===r.length)throw new Error("Props `plugins` cannot be empty. Pass an array of plugins");const e=Pe(r),t=function(e){const t={};return e.forEach((e=>t[e.type]=e)),t}(e);return{yooptaPlugins:e,PLUGINS_MAP:t}}),[r]),{yooptaPlugins:T,PLUGINS_MAP:H}=C,R=s((()=>{let e=(e=>{const{insertData:t}=e;return e.insertData=n=>{if(!e.selection)return;const r=n.getData("text/html");if(r){const t=rr(r,e.plugins);return console.log("fragment",t),void h.insertFragment(e,t)}t(n)},e})((e=>{const{deleteFragment:t}=e;return e.deleteFragment=()=>{const{selection:n}=e;if(!n)return;const[,r]=u.first(e,[0]),[,o]=u.last(e,[e.children.length-1]),i=u.range(e,r,o);if(y.equals(n,i))return h.removeNodes(e,{mode:"highest",hanging:!0}),void h.select(e,[0]);t()},e})((e=>{const{normalizeNode:t}=e;return e.normalizeNode=n=>{const[r]=n;if(u.isEditor(r)&&0===e.children.length){const t=tt(Te());h.insertNodes(e,t,{at:[0]})}else t(n)},e})((e=>{const{insertBreak:t,deleteBackward:n}=e;return e.insertBreak=()=>{if(!e.selection||!y.isCollapsed(e.selection))return t();const n=p.parent(e.selection.anchor.path),r=m.get(e,n);g.isElement(r)&&u.isVoid(e,r)?u.insertNode(e,{id:Te(),type:"paragraph",children:[{text:""}],nodeType:"block"}):t()},e.deleteBackward=t=>{if(!e.selection||!y.isCollapsed(e.selection)||0!==e.selection.anchor.offset)return n(t);const r=p.parent(e.selection.anchor.path),o=m.get(e,r);if(0===m.string(o).length&&p.hasPrevious(r)){const t=p.previous(r),n=m.get(e,t);if(g.isElement(n)&&u.isVoid(e,n))return h.removeNodes(e),h.select(e,t)}n(t)},e})((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 r=n[n.length-1];L.withoutSaving(t,(()=>{u.withoutNormalizing(t,(()=>{for(var e of r)t.apply(e)}))})),e.redos.pop(),e.undos.push(r)}},t.undo=()=>{var{history:e}=t,{undos:n}=e;if(n.length>0){var r=n[n.length-1];L.withoutSaving(t,(()=>{u.withoutNormalizing(t,(()=>{var e=r.map(f.inverse).reverse();for(var n of e)t.apply(n)}))})),e.redos.push(r),e.undos.pop()}},t.apply=e=>{var{operations:r,history:o}=t,{undos:i}=o,a=i[i.length-1],s=a&&a[a.length-1],l=F(e,s),c=L.isSaving(t),d=L.isMerging(t);if(null==c&&(c=B(e)),c){if(null==d&&(d=null!=a&&(0!==r.length||M(e,s)||l)),a&&d)l&&a.pop(),a.push(e);else{var u=[e];i.push(u)}for(;i.length>100;)i.shift();z(e)&&(o.redos=[])}n(e)},t})((e=>{const{insertText:t}=e;return e.insertText=n=>{var r,o;const{selection:i}=e;if(" "===n&&i&&y.isCollapsed(i)){const{anchor:a}=i,s=u.above(e,{match:t=>g.isElement(t)&&u.isBlock(e,t),mode:"lowest"});if(!s)return;const[,l]=s,c=u.parent(e,l),[d]=c;if(g.isElement(d)&&!v.isText(d.children[0]))return t(n);const f=s?l:[],p={anchor:a,focus:u.start(e,f)},y=u.string(e,p),m=null===(r=e.shortcuts)||void 0===r?void 0:r[y];if(m)return h.select(e,p),h.delete(e),void(null===(o=m.createElement)||void 0===o||o.call(m,e))}t(n)},e})(E(b())))))));e.plugins=H;const t={};return T.forEach((n=>{var r;n.shortcut&&(Array.isArray(n.shortcut)?n.shortcut.forEach((e=>t[e]=n)):t[n.shortcut]=n),e=(null===(r=n.extendEditor)||void 0===r?void 0:r.call(n,e))||e})),e.shortcuts=t,e}),[T]);return i((()=>{if(O)try{const[,e]=u.first(R,[0]);h.select(R,{anchor:{path:e,offset:0},focus:{path:e,offset:0}}),w.focus(R)}catch(e){}}),[O,R]),e(j,Object.assign({editor:R,initialValue:P,onChange:A},{children:e(it,{children:e(Rt,Object.assign({plugins:T,marks:a,tools:N},{children:e(Mn,{editor:R,readOnly:l,placeholder:_,plugins:T,marks:a,PLUGINS_MAP:H,className:k})}))})}),t)},ir=t=>e(S,{children:e(or,Object.assign({},t,{value:t.value,onChange:t.onChange}))});function ar({type:t,hotkey:n,className:r,as:o}){return Object.freeze({type:t,hotkey:n,render:n=>e(o||"span",Object.assign({},n.attributes,{className:ct(r,`yoopta-leaf-${t}`)},{children:n.children}))})}function sr(e){const{element:t,HTMLAttributes:n,className:r}=e;return`yoopta-${t.type} ${(null==n?void 0:n.className)||""} ${r}`}const lr={ElementOptions:Qt,Overlay:kt};export{Sn as HOTKEYS,lr as UI_HELPERS,Ne as YooptaPlugin,ar as createYooptaMark,Se as createYooptaPlugin,ct as cx,Fe as deepClone,ir as default,Je as disableBodyScroll,Xe as enableBodyScroll,Te as generateId,Dn as getElementByPath,sr as getElementClassname,On as isCodeHotkey,Pn as isElementActive,_n as isHotkey,xn as isKeyHotkey,Le as isValidYooptaNodes,Pe as mergePlugins,Wt as useElements,Vt as useMarks,at as useNodeElementSettings,Ut as useTools,It as useYoopta};
13
+ st={get exports(){return lt},set exports(e){lt=e}},function(){var e={}.hasOwnProperty;function t(){for(var n=[],r=0;r<arguments.length;r++){var o=arguments[r];if(o){var i=typeof o;if("string"===i||"number"===i)n.push(o);else if(Array.isArray(o)){if(o.length){var a=t.apply(null,o);a&&n.push(a)}}else if("object"===i){if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]")){n.push(o.toString());continue}for(var s in o)e.call(o,s)&&o[s]&&n.push(s)}}}return n.join(" ")}st.exports?(t.default=t,st.exports=t):window.classNames=t}();var ct=lt;function dt(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}var ut="u-OdDyDx",ft="xA0VqV0c";dt(".u-OdDyDx:after{color:#aaa;content:attr(data-placeholder);font-size:75%;font-style:inherit;font-weight:inherit;padding-left:5px;position:absolute;text-indent:2px;top:50%;transform:translateY(-50%);user-select:none}.xA0VqV0c{background-color:#accef7}");const pt={margin:"1px 0",whiteSpace:"pre-wrap",wordBreak:"break-word",color:"inherit",fontSize:"inherit",lineHeight:"inherit",fontWeight:"inherit"},ht=l((({attributes:t,children:n,placeholder:r,leaf:o})=>{const i=O();return e("span",Object.assign({},t,{"data-placeholder":r,style:pt,className:ct({[ut]:o.withPlaceholder&&r&&i,[ft]:o.selection})},{children:n}))}));ht.displayName="TextLeaf";var gt;function vt(){return vt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},vt.apply(this,arguments)}var yt,mt=function(e){return n.createElement("svg",vt({viewBox:"0 0 10 10",fill:"currentColor",style:{width:14,height:14,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),gt||(gt=n.createElement("path",{d:"M3 2a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm4-8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm0 4a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"})))};function bt(){return bt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bt.apply(this,arguments)}var wt=function(e){return n.createElement("svg",bt({viewBox:"0 0 16 16",fill:"currentColor",style:{width:16,height:16,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),yt||(yt=n.createElement("path",{d:"M7.977 14.963c.407 0 .747-.324.747-.723V8.72h5.362c.399 0 .74-.34.74-.747a.746.746 0 0 0-.74-.738H8.724V1.706c0-.398-.34-.722-.747-.722a.732.732 0 0 0-.739.722v5.529h-5.37a.746.746 0 0 0-.74.738c0 .407.341.747.74.747h5.37v5.52c0 .399.332.723.739.723z"})))},_t="QEROK9NJ",Ot="ZLDKsGEc",xt="_0wBAdXIb",Et="P40m4iJS",jt="_7iHqOybQ";dt(".QEROK9NJ{inset:0;overflow:hidden;pointer-events:none;position:fixed;z-index:999}.ZLDKsGEc,._0wBAdXIb{position:relative;z-index:0}._0wBAdXIb{pointer-events:auto}.P40m4iJS{height:100vh;left:0;position:fixed;top:0;width:100vw}._7iHqOybQ{pointer-events:auto;position:relative;top:100%}");const kt=({children:n,onClose:r})=>{const[a]=o((()=>document.createElement("div")));return i((()=>(a.className="yoopta-overlay",document.body.appendChild(a),()=>{document.body.removeChild(a)})),[a]),N(t("div",Object.assign({className:_t},{children:[e("div",{className:Ot}),t("div",Object.assign({className:xt},{children:[e("div",{className:Et,onClick:r}),e("div",Object.assign({className:jt,onClick:e=>e.stopPropagation()},{children:n}))]}))]})),a)};var Nt;function St(){return St=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},St.apply(this,arguments)}var Pt,Dt=function(e){return n.createElement("svg",St({viewBox:"0 0 16 16",className:"trash_svg__trash",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Nt||(Nt=n.createElement("path",{d:"M4.862 15.429h6.283c1.045 0 1.722-.636 1.77-1.689l.465-9.85h.752c.342 0 .608-.26.608-.602a.594.594 0 0 0-.608-.595H11.09V1.668C11.09.622 10.427 0 9.292 0H6.694C5.566 0 4.896.622 4.896 1.668v1.025H1.861a.598.598 0 1 0 0 1.196h.76l.464 9.858c.048 1.053.718 1.682 1.777 1.682Zm1.292-13.7c0-.355.246-.58.63-.58h2.42c.382 0 .628.225.628.58v.964H6.154V1.73ZM4.992 14.22c-.376 0-.65-.274-.67-.677L3.864 3.89h8.251l-.444 9.652c-.014.403-.287.677-.677.677H4.992Zm.991-1.1c.288 0 .472-.185.465-.452l-.205-7.164c-.007-.274-.198-.451-.472-.451-.287 0-.471.184-.464.45l.205 7.165c.007.273.198.451.471.451Zm2.017 0c.287 0 .479-.185.479-.452V5.503c0-.267-.192-.451-.479-.451s-.479.184-.479.45v7.165c0 .267.192.451.479.451Zm2.017 0c.273 0 .458-.179.464-.452l.212-7.164c.007-.267-.184-.451-.464-.451-.274 0-.465.177-.472.45l-.212 7.165c-.007.267.184.451.472.451Z"})))};function At(){return At=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},At.apply(this,arguments)}var Ct,Tt=function(e){return n.createElement("svg",At({viewBox:"0 0 16 16",className:"duplicate_svg__duplicate",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Pt||(Pt=n.createElement("path",{d:"M2.839 12.152H4v1.033c0 1.456.759 2.214 2.242 2.214h6.918c1.477 0 2.242-.758 2.242-2.214V6.212c0-1.456-.765-2.215-2.242-2.215H12V2.965c0-1.456-.766-2.215-2.242-2.215H2.839C1.362.75.597 1.502.597 2.965V9.93c0 1.463.765 2.221 2.242 2.221Zm.082-1.34c-.636 0-.984-.328-.984-.99v-6.74c0-.664.348-.999.984-.999h6.76c.63 0 .985.335.985.998v.916H6.243c-1.483 0-2.242.759-2.242 2.215v4.6h-1.08Zm3.397 3.248c-.635 0-.977-.329-.977-.992v-6.74c0-.663.342-.991.977-.991h6.761c.629 0 .984.328.984.991v6.74c0 .663-.355.992-.984.992H6.32Z"})))};function Lt(){return Lt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Lt.apply(this,arguments)}var Mt,Bt=function(e){return n.createElement("svg",Lt({viewBox:"0 0 16 16",className:"turn_svg__loop",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Ct||(Ct=n.createElement("path",{d:"M5.804 3.123c.006.38.254.622.673.622h4.887c.59 0 .914.305.914.92v6.628l-.901-.978-.514-.514c-.267-.254-.629-.273-.895-.013-.254.26-.248.635.012.895l2.165 2.158c.476.47 1.022.47 1.498 0l2.165-2.158c.26-.26.266-.635.012-.895-.266-.26-.628-.241-.895.013l-.514.514-.895.971V4.564c0-1.358-.71-2.063-2.082-2.063H6.477c-.42 0-.68.241-.673.622ZM.186 7.06c.26.266.622.247.889-.013l.52-.508.889-.971v6.722c0 1.359.71 2.063 2.082 2.063h4.957c.42 0 .68-.241.673-.622-.006-.387-.254-.622-.673-.622h-4.88c-.591 0-.915-.311-.915-.927V5.554l.895.984.52.508c.26.26.629.28.89.013.26-.26.253-.629-.013-.89L3.855 4.013c-.476-.476-1.016-.476-1.492 0L.2 6.17c-.267.26-.273.628-.013.889Z"})))};function Ft(){return Ft=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ft.apply(this,arguments)}var zt=function(e){return n.createElement("svg",Ft({viewBox:"0 0 16 16",className:"copy_svg__link",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Mt||(Mt=n.createElement("path",{d:"m7.7 10.895 1.038-1.046c-.82-.076-1.394-.335-1.818-.76-1.155-1.154-1.155-2.795-.007-3.943l2.27-2.27c1.155-1.155 2.789-1.155 3.944 0 1.162 1.169 1.155 2.796.007 3.944l-1.176 1.176a2.74 2.74 0 0 1 .17 1.634l1.963-1.955c1.682-1.675 1.688-4.054-.007-5.75C12.389.225 10.01.238 8.335 1.913L5.956 4.298c-1.675 1.675-1.688 4.054.007 5.749.403.396.943.697 1.736.848Zm.6-5.763L7.27 6.178c.813.075 1.394.342 1.811.759 1.162 1.162 1.162 2.795.007 3.944l-2.27 2.27c-1.155 1.155-2.782 1.155-3.944 0-1.162-1.163-1.155-2.796 0-3.945L4.042 8.03a2.788 2.788 0 0 1-.17-1.634L1.915 8.352c-1.682 1.674-1.688 4.06.007 5.755 1.695 1.696 4.074 1.682 5.749.007l2.372-2.379c1.682-1.681 1.688-4.06-.007-5.749-.396-.403-.936-.704-1.736-.854Z"})))};const Ht=r.createContext({marks:{},elements:{}}),Rt=({children:t,plugins:n,marks:o,tools:i})=>{const a=_(),l=c(),d=e=>{if(!a.selection)return!1;const[t]=u.nodes(a,{at:u.unhangRange(a,a.selection),match:t=>!u.isEditor(t)&&g.isElement(t)&&t.type===e,mode:"highest"});return!!t},f=()=>{const e={};return n.forEach((t=>{const{createElement:n,defineElement:r,type:o,options:i,hasParent:s}=t;e[t.type]={create:n,define:r,toggle:e=>((e,t)=>{u.withoutNormalizing(a,(()=>{var n;if(!a.selection)return;const{offset:r,path:o}=a.selection.anchor,{shouldDeleteText:i}=t||{};i&&h.delete(a,{at:{anchor:{path:o,offset:0},focus:{path:o,offset:r}}});const s=u.above(a,{at:a.selection,mode:"highest",match:e=>!u.isEditor(e)&&g.isElement(e)}),[l,c]=u.parent(a,p.parent(a.selection.anchor.path)),[d]=s||[];(null==d?void 0:d.type)!==e.type?(g.isElement(l)&&!u.isEditor(l)&&h.unwrapNodes(a,{at:c,match:e=>!u.isEditor(e)&&!v.isText(e)&&g.isElement(l)&&e.type===l.type}),null===(n=e.createElement)||void 0===n||n.call(e,a,{id:d.id})):h.setNodes(a,tt(Te()),{mode:"highest",match:e=>!u.isEditor(e)&&g.isElement(e)})}))})(t,e),type:o,isActive:!s&&d(o),options:{displayLabel:null==i?void 0:i.displayLabel}}})),e},y=s((()=>f()),[n,a.selection]),m=e=>{const t=u.marks(a);return!!(null==t?void 0:t[e])},b=s((()=>{const e={};return null==o||o.forEach((t=>{e[t.type]={toggle:e=>((e,t=!1)=>{t&&Object.keys(u.marks(a)||{}).forEach((e=>{u.removeMark(a,e)})),m(e)?u.removeMark(a,e):u.addMark(a,e,!0)})(t.type,null==e?void 0:e.only),isActive:m(t.type)}})),e}),[o,a.selection]),w=s((()=>{const e=Object.keys(i||{});if(0===e.length)return;const t={};return e.forEach((e=>{const o=null==i?void 0:i[e];o&&r.isValidElement(o)&&(t[e]=e=>{var{style:t,className:i}=e,a=H(e,["style","className"]);return r.cloneElement(o,Object.assign(Object.assign({style:t,className:i,plugins:n,fromHook:!0},null==o?void 0:o.props),a))})})),t}),[i]);return l.current={elements:y,marks:b,tools:w},e(Ht.Provider,Object.assign({value:l.current},{children:t}))},It=()=>a(Ht),Vt=()=>a(Ht).marks,Wt=()=>a(Ht).elements,Ut=()=>a(Ht).tools;var Zt="IMJgzRnZ",$t="nFfAiJWo",qt="DeARgIyF",Kt="kyuzONcU",Gt="_95up7F66",Jt="_9d0T-cEo";dt(".IMJgzRnZ{align-items:center;background:#fff;border-radius:4px;box-shadow:0 0 0 1px hsla(0,0%,6%,.05),0 3px 6px hsla(0,0%,6%,.1),0 9px 24px hsla(0,0%,6%,.2);display:flex;flex-direction:column;height:auto;max-height:70vh;max-width:calc(100vw - 24px);min-width:200px;opacity:1;overflow:hidden;position:fixed;transform-origin:0 top;width:auto}.nFfAiJWo{flex-grow:1;margin-bottom:0;margin-right:0;min-height:0;overflow:hidden auto;position:relative;transform:translateZ(0);width:100%;z-index:1}.DeARgIyF{box-shadow:0 -1px 0 rgba(55,53,47,.09);padding-bottom:6px;padding-top:6px}.kyuzONcU{align-items:center;background:inherit;border:none;border-radius:3px;color:#000;cursor:pointer;display:flex;font-size:14px;line-height:120%;margin-left:4px;margin-right:4px;min-height:28px;transition:background 20ms ease-in 0s;user-select:none;width:calc(100% - 8px)}.kyuzONcU:hover{background-color:rgba(55,53,47,.08);color:#000}._95up7F66{align-items:center;color:#000;display:flex;justify-content:center;margin-left:10px;margin-right:4px}._9d0T-cEo{flex:1 1 auto;margin-left:6px;margin-right:6px;overflow:hidden;text-align:left;text-overflow:ellipsis}._5FdNFUNm,._9d0T-cEo{min-width:0;white-space:nowrap}._5FdNFUNm{color:rgba(55,53,47,.5);flex-shrink:0;font-size:12px;margin-left:auto;margin-right:12px}");const Xt={position:"fixed",opacity:1,bottom:"auto",right:"auto"},Qt=n=>{var{onClose:r,style:i,element:a,render:s}=n,l=H(n,["onClose","style","element","render"]);const[d,f]=o({style:Xt,open:!1}),p=c(null),h=_(),g=Ut(),[,v]=at(),{ActionMenu:y}=g||{},m=!!y,b=u.isVoid(h,a),w=()=>f({style:Xt,open:!1});return e(kt,Object.assign({onClose:r},{children:e("div",Object.assign({style:i,className:ct(Zt,"yoopta-element-options"),ref:p},{children:t("div",Object.assign({className:$t},{children:[d.open&&y&&e(kt,Object.assign({onClose:w},{children:y&&e(y,{style:d.style,options:{shouldDeleteText:!1},on:{toggle:()=>{w(),v.closeNodeSettings()}}})})),t("div",Object.assign({className:qt},{children:[t("button",Object.assign({type:"button",className:Kt,onClick:()=>{var e;v.deleteNode(),null===(e=l.onDelete)||void 0===e||e.call(l)}},{children:[e("div",Object.assign({className:Gt},{children:e(Dt,{})})),e("div",Object.assign({className:Jt},{children:"Delete"}))]})),t("button",Object.assign({type:"button",className:Kt,onClick:()=>{var e;v.duplicateNode(),null===(e=l.onDuplicate)||void 0===e||e.call(l)}},{children:[e("div",Object.assign({className:Gt},{children:e(Tt,{})})),e("div",Object.assign({className:Jt},{children:"Duplicate"}))]})),!b&&m&&t("button",Object.assign({type:"button",className:Kt,onClick:e=>{var t;const n=p.current.getBoundingClientRect(),r=null===(t=document.querySelector(".yoopta-action-menu-list"))||void 0===t?void 0:t.getBoundingClientRect(),o={left:n.left+n.width+10,top:n.top+n.height};r&&o.left+r.width>window.innerWidth&&(o.left=n.left-r.width-10),r&&o.top<r.height&&(o.top=r.height+20),f((e=>({open:!e.open,style:Object.assign(Object.assign({},e.style),o)})))}},{children:[e("div",Object.assign({className:Gt},{children:e(Bt,{})})),e("div",Object.assign({className:Jt},{children:"Turn into"}))]})),t("button",Object.assign({type:"button",className:Kt,onClick:()=>{var e;v.copyLinkNode(),null===(e=l.onCopy)||void 0===e||e.call(l)}},{children:[e("div",Object.assign({className:Gt},{children:e(zt,{})})),e("div",Object.assign({className:Jt},{children:"Copy link to block"}))]}))]}))]}))}))}))};var Yt="yCQ-VdE5",en="b--398nS",tn="_6VhqH6wy",nn="k9i48GWd",rn="TNeDy6y5",on="jVfkavqE",an="_87oFW01f",sn="oz5S7EmO";dt('.yCQ-VdE5{display:flex;left:-50px;opacity:0;position:absolute;top:2px;transition:opacity .18s ease-in}.b--398nS{opacity:1}._6VhqH6wy{all:unset;align-items:center;background-color:inherit;background-color:transparent;border-radius:6px;color:rgba(55,53,47,.35);cursor:pointer;display:flex;height:24px;justify-content:center;margin:0 1px;padding:0;position:relative;transition:background-color .18s cubic-bezier(.4,0,.2,1);width:auto;width:18px}._6VhqH6wy:active,._6VhqH6wy:focus,._6VhqH6wy:hover{background-color:rgba(55,54,47,.08)}.k9i48GWd{width:24px}.TNeDy6y5{position:relative;transition:opacity .18s cubic-bezier(.4,0,.2,1)}.jVfkavqE:after{background-color:#007aff;bottom:-7px;content:"";height:3px;left:50%;position:absolute;transform:translateX(-50%);width:100%}._87oFW01f:before{top:-5px}._87oFW01f:after,._87oFW01f:before{background-color:inherit;content:"";height:3px;left:50%;position:absolute;transform:translateX(-50%);width:100%}._87oFW01f:after{bottom:-7px}.oz5S7EmO{background:rgba(35,131,226,.14);border-radius:3px;inset:0;opacity:1;pointer-events:none;position:absolute;transition:background-color .18s cubic-bezier(.4,0,.2,1);z-index:81}');const ln=({element:n,editor:r,values:o,handlers:i})=>{const a=c(null),{hoveredElement:s,isElementOptionsOpen:l,nodeSettingsPos:d}=o,{onDragEnd:f,onDragStart:p,openNodeSettings:h,closeNodeSettings:v,triggerPlusButton:y}=i,m=e=>{e.stopPropagation();const t=a.current,o=document.querySelector(`[data-element-id="${null==n?void 0:n.id}"]`),i=w.findPath(r,n),s=u.parent(r,i);g.isElement(n)&&(null==t||t.setAttribute("draggable","false"),o&&(o.setAttribute("draggable","true"),o.ondragstart=e=>{const t={path:i,element:{id:n.id,type:n.type},parent:s};p(e,t)},o.ondragend=f))},b=(null==s?void 0:s.id)===n.id;return t("div",Object.assign({contentEditable:!1,className:ct(Yt,{[en]:b},"yoopta-element-actions")},{children:[b&&l&&e(Qt,{element:n,style:d||void 0,onClose:v}),e("button",Object.assign({type:"button",onMouseDown:m,className:ct(tn,nn,"yoopta-element-actions-plus"),onClick:()=>y(n)},{children:e(wt,{})})),e("button",Object.assign({type:"button",onMouseDown:m,className:ct(tn,"yoopta-element-actions-drag"),onClick:()=>h(a,n),ref:a},{children:e(mt,{})}))]}))},cn=({children:n,element:r,attributes:o,nodeType:i,render:a,HTMLAttributes:l})=>{var c,d;const u=_(),[f,p]=at(),h="inline"===i,{hoverIn:g,onDrop:v}=p,{dndState:y,DRAG_MAP:m}=f,b=s((()=>{var e,t;if(null===y.from.element||null===y.to.element)return{isDragging:!1,isDragOver:!1,isDragSelf:!1};const n=(null===(e=f.dndState.from.element)||void 0===e?void 0:e.id)===r.id,o=(null===(t=f.dndState.to.element)||void 0===t?void 0:t.id)===r.id;return{isDragging:n,isDragOver:o,isDragSelf:n&&o}}),[f.dndState.from,f.dndState.to]),w=null===(c=r.data)||void 0===c?void 0:c.skipSettings,{isDragging:O,isDragOver:x,isDragSelf:E}=b,j={opacity:O?.7:1};return m.set(r.id,r),h?a({attributes:o,element:r,children:n,HTMLAttributes:l}):t("div",Object.assign({"data-element-id":r.id,"data-element-type":r.type,onMouseEnter:e=>{w||g(e,r)},onDrop:v,className:ct(rn,{[on]:x,[an]:E}),style:j},o,{children:[w?null:e(ln,{editor:u,element:r,handlers:p,values:f}),a({attributes:o,element:r,children:n,HTMLAttributes:l}),(null===(d=f.selectedNodeElement)||void 0===d?void 0:d.id)===r.id&&e("div",{className:ct(sn,"yoopta-selected-node-element")})]}))};cn.displayName="ElementWrapper";var dn={};Object.defineProperty(dn,"__esModule",{value:!0});for(var un="undefined"!=typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),fn={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},pn={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:un?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},hn={backspace:8,tab:9,enter:13,shift:16,control:17,alt:18,pause:19,capslock:20,escape:27," ":32,pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,insert:45,delete:46,meta:91,numlock:144,scrolllock:145,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},gn=1;gn<20;gn++)hn["f"+gn]=111+gn;function vn(e,t,n){t&&!("byKey"in t)&&(n=t,t=null),Array.isArray(e)||(e=[e]);var r=e.map((function(e){return yn(e,t)})),o=function(e){return r.some((function(t){return mn(t,e)}))};return null==n?o:o(n)}function yn(e,t){var n=t&&t.byKey,r={},o=(e=e.replace("++","+add")).split("+"),i=o.length;for(var a in fn)r[fn[a]]=!1;var s=!0,l=!1,c=void 0;try{for(var d,u=o[Symbol.iterator]();!(s=(d=u.next()).done);s=!0){var f=d.value,p=f.endsWith("?")&&f.length>1;p&&(f=f.slice(0,-1));var h=wn(f),g=fn[h];if(f.length>1&&!g&&!pn[f]&&!hn[h])throw new TypeError('Unknown modifier: "'+f+'"');1!==i&&g||(n?r.key=h:r.which=bn(f)),g&&(r[g]=!p||null)}}catch(e){l=!0,c=e}finally{try{!s&&u.return&&u.return()}finally{if(l)throw c}}return r}function mn(e,t){for(var n in e){var r=e[n],o=void 0;if(null!=r&&((null!=(o="key"===n&&null!=t.key?t.key.toLowerCase():"which"===n?91===r&&93===t.which?91:t.which:t[n])||!1!==r)&&o!==r))return!1}return!0}function bn(e){return e=wn(e),hn[e]||e.toUpperCase().charCodeAt(0)}function wn(e){return e=e.toLowerCase(),e=pn[e]||e}dn.default=vn;var _n=dn.isHotkey=vn,On=dn.isCodeHotkey=function(e,t){return vn(e,t)},xn=dn.isKeyHotkey=function(e,t){return vn(e,{byKey:!0},t)};dn.parseHotkey=yn,dn.compareHotkey=mn,dn.toKeyCode=bn,dn.toKeyName=wn;const En={bold:"mod+b",italic:"mod+i",compose:["down","left","right","up","backspace","enter"],arrowLeft:"left",arrowUp:"up",arrowDown:"down",arrowRight:"right",ctrlLeft:"ctrl+left",escape:"esc",ctrlRight:"ctrl+right",deleteBackward:"shift?+backspace",backspace:"backspace",deleteForward:"shift?+delete",extendBackward:"shift+left",extendForward:"shift+right",shiftEnter:"shift+enter",enter:"enter",space:"space",undo:"mod+z",select:"mod+a",shiftTab:"shift+tab",tab:"tab",cmd:"mod",cmdEnter:"mod+enter",kekCeburek:"mod+enter"},jn={moveLineBackward:"opt+up",moveLineForward:"opt+down",ctrlLeft:"opt+left",ctrlRight:"opt+right",deleteBackward:["ctrl+backspace","ctrl+h"],deleteForward:["ctrl+delete","ctrl+d"],deleteLineBackward:"cmd+shift?+backspace",deleteLineForward:["cmd+shift?+delete","ctrl+k"],deleteWordBackward:"opt+shift?+backspace",deleteWordForward:"opt+shift?+delete",extendLineBackward:"opt+shift+up",extendLineForward:"opt+shift+down",redo:"cmd+shift+z",transposeCharacter:"ctrl+t"},kn={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},Nn=e=>{const t=En[e],n=jn[e],r=kn[e],o=t&&xn(t),i=n&&xn(n),a=r&&xn(r);return e=>!(!o||!o(e))||(!(!i||!i(e))||!(!a||!a(e)))},Sn={isBold:Nn("bold"),isCompose:Nn("compose"),isArrowLeft:Nn("arrowLeft"),isArrowRight:Nn("arrowRight"),isArrowUp:Nn("arrowUp"),isArrowDown:Nn("arrowDown"),isDeleteBackward:Nn("deleteBackward"),isDeleteForward:Nn("deleteForward"),isDeleteLineBackward:Nn("deleteLineBackward"),isDeleteLineForward:Nn("deleteLineForward"),isDeleteWordBackward:Nn("deleteWordBackward"),isDeleteWordForward:Nn("deleteWordForward"),isExtendBackward:Nn("extendBackward"),isExtendForward:Nn("extendForward"),isExtendLineBackward:Nn("extendLineBackward"),isExtendLineForward:Nn("extendLineForward"),isItalic:Nn("italic"),isMoveLineBackward:Nn("moveLineBackward"),isMoveLineForward:Nn("moveLineForward"),isCtrlLeft:Nn("ctrlLeft"),isCtrlRight:Nn("ctrlRight"),isRedo:Nn("redo"),isShiftEnter:Nn("shiftEnter"),isEnter:Nn("enter"),isTransposeCharacter:Nn("transposeCharacter"),isUndo:Nn("undo"),isSpace:Nn("space"),isSelect:Nn("select"),isTab:Nn("tab"),isShiftTab:Nn("shiftTab"),isBackspace:Nn("backspace"),isCmdEnter:Nn("cmdEnter"),isCmd:Nn("cmd"),isEscape:Nn("escape"),isKekceburek:Nn("kekCeburek")},Pn=(e,t)=>!!((e,t)=>{const{selection:n}=e;if(!n)return!1;const[r]=Array.from(u.nodes(e,{at:u.unhangRange(e,n),match:e=>!u.isEditor(e)&&g.isElement(e)&&e.type===t}));return r})(e,t),Dn=(e,t,n="lowest")=>{var r;const o=Array.from(u.nodes(e,{match:t=>u.isEditor(e)&&g.isElement(t),at:t||(null===(r=e.selection)||void 0===r?void 0:r.anchor.path),mode:n}))[0];return o?o[0]:e.children[0]};function An(e,t){var n,r;if(v.isText(e))return function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return e.replace(/[&<>"']/g,(e=>t[e]))}(e.text);const o=e.children.map((e=>An(e,t))).join(""),i=t[e.type];return"function"==typeof(null===(r=null===(n=i.exports)||void 0===n?void 0:n.html)||void 0===r?void 0:r.serialize)?i.exports.html.serialize(e,o):o}function Cn(e,t){return e.map((e=>An(e,t))).join("")}const Tn={outline:"none"},Ln={hotkeys:Sn,defaultNode:tt(Te())},Mn=({editor:n,placeholder:r,marks:o,readOnly:a,plugins:l,className:f,PLUGINS_MAP:v})=>{i((()=>{const e=window.location.hash.length>0?window.location.hash.replace("#",""):null;if(e){const t=document.getElementById(e)||document.querySelector(`[data-element-id="${e}"]`);t&&window.scrollTo({top:t.offsetTop,behavior:"smooth"})}}),[]);const m=c(null),[{disableWhileDrag:b},{changeHoveredNode:_}]=at(),O=Ut(),{ActionMenu:E,Toolbar:j}=O||{},k=b||a,N=s((()=>t=>{var r;const o=v[t.element.type];if(!o)return null;const i=function(e){return"function"==typeof e.renderer?e.renderer:e.renderer.editor}(o)(n,o);return e(cn,Object.assign({element:t.element,attributes:t.attributes,nodeType:t.element.nodeType,render:i,HTMLAttributes:null===(r=o.options)||void 0===r?void 0:r.HTMLAttributes},{children:t.children}))}),[l,n]),S=s((()=>e=>{const t=[],[r,o]=e;return l.forEach((o=>{const i=o.decorator;"function"==typeof i&&g.isElement(r)&&r.type===o.type&&t.push(...i(n)(e))})),n.selection&&!u.isEditor(r)&&""===u.string(n,[o[0]])&&y.includes(n.selection,o)&&y.isCollapsed(n.selection)&&t.push(Object.assign(Object.assign({},n.selection),{withPlaceholder:!0})),t}),[l,n]),P=s((()=>t=>{var i;const a=Object.assign({},t);let s;l.forEach((e=>{if(e.leaf){const t=e.leaf(n)(a);t&&(a.children=t)}})),null==o||o.forEach((e=>{a.leaf[e.type]&&(a.children=e.render(a))}));const c=null===(i=a.children.props)||void 0===i?void 0:i.parent;if(!function(e){var t,n;return 1!==(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)||0!==(null===(n=null==e?void 0:e.children[0])||void 0===n?void 0:n.text.length)}(c)){const e=v[null==c?void 0:c.type];s=null===(null==e?void 0:e.placeholder)?null:(null==e?void 0:e.placeholder)||r}return e(ht,Object.assign({},a,{placeholder:s}))}),[l,n]),D=s((()=>{const e=l.map((e=>Object.keys(e.events||{}))).flat().filter(((e,t,n)=>n.indexOf(e)===t)),t={};return e.forEach((e=>{t[e]=function(t){l.forEach((r=>{var o;if(null===(o=r.events)||void 0===o?void 0:o[e]){r.events[e](n,Ln)(t)}}))}})),t}),[l,n]),A=d((e=>{u.withoutNormalizing(n,(()=>{var t;if(!n.selection)return;const r=tt(Te());null==o||o.forEach((t=>{t.hotkey&&xn(t.hotkey)(e)&&(e.preventDefault(),nt(n,t.type,!1))})),null===(t=D.onKeyDown)||void 0===t||t.call(D,e);const i=u.above(n,{match:e=>!u.isEditor(e),mode:"lowest"});if(Sn.isEnter(e)){if(e.isDefaultPrevented())return;e.preventDefault();const t=Object.keys(u.marks(n)||{});t.length>0&&t.forEach((e=>u.removeMark(n,e)));const o=p.parent(n.selection.anchor.path),a=u.string(n,o),s=i&&i[0].type!==r.type;if(s&&0===a.length)return void h.setNodes(n,r,{at:o});if(u.isStart(n,n.selection.anchor,n.selection.anchor.path)&&s){const[e]=i;return h.setNodes(n,r,{at:o}),h.delete(n,{unit:"block"}),h.insertNodes(n,Fe(e),{at:p.next(o)}),void h.select(n,{path:[p.next(n.selection.anchor.path)[0]+1,0],offset:0})}return h.splitNodes(n,{always:!0}),h.setNodes(n,r),void _(r)}if(Sn.isShiftEnter(e)){if(e.isDefaultPrevented())return;e.preventDefault(),n.insertText("\n")}if(Sn.isSelect(e)){if(e.isDefaultPrevented())return;e.preventDefault();const t=u.above(n,{at:n.selection.anchor.path,match:e=>!u.isEditor(e)&&g.isElement(e)});if(!t)return;const r=u.string(n,t[1]);return y.isExpanded(n.selection)||0===r.length?void h.select(n,[]):void h.select(n,t[1])}}))}),[]);return t("div",Object.assign({id:"yoopta-editor",className:f,ref:m,onMouseDown:e=>{a||(e.preventDefault(),e.currentTarget===e.target&&n.selection&&u.withoutNormalizing(n,(()=>{const e=[n.children.length-1,0],t=Dn(n,e,"highest"),r=u.string(n,e),o={anchor:{path:e,offset:0},focus:{path:e,offset:0}};if("paragraph"===t.type&&0===r.length)return h.select(n,{path:o.anchor.path,offset:0}),_(t),w.focus(n);const i=tt(Te());_(i),h.insertNodes(n,i,{at:[n.children.length],select:!0}),w.focus(n)})))}},{children:[!!E&&e(E,{}),!!j&&e(j,{}),e(x,Object.assign({id:"yoopta-contenteditable",renderLeaf:P,renderElement:N,readOnly:k,decorate:S,onCopy:e=>{if(!n.selection)return;const t=Cn(u.fragment(n,n.selection),n.plugins);return e.clipboardData.setData("text/html",t),e.clipboardData},spellCheck:!0},D,{onKeyDown:A,onMouseDown:e=>{var t;null===(t=D.onMouseDown)||void 0===t||t.call(D,e),(e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()})(e)},style:Tn}))]}))};function Bn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Fn=new WeakMap,zn=new WeakMap;class Hn{}class Rn extends Hn{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super();var{offset:t,path:n}=e;this.offset=t,this.path=n}}class In extends Hn{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super();var{offset:t,path:n}=e;this.offset=t,this.path=n}}var Vn=e=>zn.get(e);function Wn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Un(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wn(Object(n),!0).forEach((function(t){Bn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Zn=new WeakSet,$n=e=>{var t=[],n=e=>{if(null!=e){var r=t[t.length-1];if("string"==typeof e){var o={text:e};Zn.add(o),e=o}if(v.isText(e)){var i=e;v.isText(r)&&Zn.has(r)&&Zn.has(i)&&v.equals(r,i,{loose:!0})?r.text+=i.text:t.push(i)}else if(g.isElement(e))t.push(e);else{if(!(e instanceof Hn))throw new Error("Unexpected hyperscript child object: ".concat(e));var a=t[t.length-1];v.isText(a)||(n(""),a=t[t.length-1]),e instanceof Rn?((e,t)=>{var n=e.text.length;Fn.set(e,[n,t])})(a,e):e instanceof In&&((e,t)=>{var n=e.text.length;zn.set(e,[n,t])})(a,e)}}};for(var r of e.flat(1/0))n(r);return t};function qn(e,t,n){return Un(Un({},t),{},{children:$n(n)})}function Kn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Gn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Kn(Object(n),!0).forEach((function(t){Bn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Kn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Jn,Xn={anchor:function(e,t,n){return new Rn(t)},cursor:function(e,t,n){return[new Rn(t),new In(t)]},editor:(Jn=b,(e,t,n)=>{var r,o=[];for(var i of n)y.isRange(i)?r=i:o.push(i);var a,s=$n(o),l={},c=Jn();for(var[d,u]of(Object.assign(c,t),c.children=s,m.texts(c))){var f=(a=d,Fn.get(a)),p=Vn(d);if(null!=f){var[h]=f;l.anchor={path:u,offset:h}}if(null!=p){var[g]=p;l.focus={path:u,offset:g}}}if(l.anchor&&!l.focus)throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<anchor />`. For collapsed selections, use `<cursor />` instead.");if(!l.anchor&&l.focus)throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<focus />`. For collapsed selections, use `<cursor />` instead.");return null!=r?c.selection=r:y.isRange(l)&&(c.selection=l),c}),element:qn,focus:function(e,t,n){return new In(t)},fragment:function(e,t,n){return $n(n)},selection:function(e,t,n){var r=n.find((e=>e instanceof Rn)),o=n.find((e=>e instanceof In));if(!r||null==r.offset||null==r.path)throw new Error("The <selection> hyperscript tag must have an <anchor> tag as a child with `path` and `offset` attributes defined.");if(!o||null==o.offset||null==o.path)throw new Error("The <selection> hyperscript tag must have a <focus> tag as a child with `path` and `offset` attributes defined.");return Un({anchor:{offset:r.offset,path:r.path},focus:{offset:o.offset,path:o.path}},t)},text:function(e,t,n){var r=$n(n);if(r.length>1)throw new Error("The <text> hyperscript tag must only contain a single node's worth of children.");var[o]=r;if(null==o&&(o={text:""}),!v.isText(o))throw new Error("\n The <text> hyperscript tag can only contain text content as children.");return Zn.delete(o),Object.assign(o,t),o}},Qn=e=>function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];var a=e[t];if(!a)throw new Error("No hyperscript creator found for tag: <".concat(t,">"));return null==n&&(n={}),D(n)||(o=[n].concat(o),n={}),a(t,n,o=o.filter((e=>Boolean(e))).flat())},Yn=e=>{var t={},n=function(n){var r=e[n];if("object"!=typeof r)throw new Error("Properties specified for a hyperscript shorthand should be an object, but for the custom element <".concat(n,"> tag you passed: ").concat(r));t[n]=(e,t,n)=>qn(0,Gn(Gn({},r),t),n)};for(var r in e)n(r);return t},er=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{elements:t={}}=e,n=Yn(t),r=Gn(Gn(Gn({},Xn),n),e.creators);return Qn(r)}();const tr={DEL:()=>({strikethrough:!0}),EM:()=>({italic:!0}),I:()=>({italic:!0}),S:()=>({strikethrough:!0}),STRONG:()=>({bold:!0}),U:()=>({underline:!0})},nr=(e,t)=>{var n,r,o,i;if(3===e.nodeType)return e.textContent;if(1!==e.nodeType)return null;if("BR"===e.nodeName)return"\n";const{nodeName:a}=e;let s=e,l=Array.from(s.childNodes).map((e=>nr(e,t))).flat();if(0===l.length&&(l=[{text:""}]),"BODY"===e.nodeName)return er("fragment",{},l);if(t[a]){const s=t[a];if(s){let t=s.defineElement();if("function"==typeof(null===(r=null===(n=s.exports)||void 0===n?void 0:n.html.deserialize)||void 0===r?void 0:r.parse)){const n=null===(i=null===(o=s.exports)||void 0===o?void 0:o.html.deserialize)||void 0===i?void 0:i.parse(e);t=Object.assign(Object.assign({},t),{data:n})}return er("element",t,l)}}if(v.isTextList(l)&&(l=l.filter((e=>""!==e.text)),l.length>0))return er("element",t.P.defineElement(),l);if(tr[a]){const t=tr[a](e);return l.map((e=>v.isText(e)?er("text",t,e):e))}return l};function rr(e,t){try{const n=function(e){const t={};return Object.keys(e).forEach((n=>{var r,o,i,a,s,l,c,d;const u=e[n];if(null===(o=null===(r=u.exports)||void 0===r?void 0:r.html.deserialize)||void 0===o?void 0:o.nodeName){if(Array.isArray(null===(a=null===(i=u.exports)||void 0===i?void 0:i.html.deserialize)||void 0===a?void 0:a.nodeName))return void(null===(l=null===(s=u.exports)||void 0===s?void 0:s.html.deserialize)||void 0===l||l.nodeName.forEach((e=>{t[e]=u})));t[null===(d=null===(c=u.exports)||void 0===c?void 0:c.html.deserialize)||void 0===d?void 0:d.nodeName]=u}})),t}(t),r=(new DOMParser).parseFromString(e,"text/html");return nr(r.body,n)}catch(e){return console.error(e),null}}const or=({key:t,value:n,plugins:r,marks:a,readOnly:l,onChange:c,placeholder:_,autoFocus:O=!0,offline:x,className:k,tools:N})=>{const S=function(e){return"string"==typeof e?e:"yoopta-content"}(x),[P,D]=o((()=>function(e,t,n){const r=[{id:Te(),type:"paragraph",children:[{text:""}]}],o=Le(n)?n:r;if(!t)return localStorage.removeItem(e),o;try{const t=JSON.parse(localStorage.getItem(e)||"[]");return Le(t)?t:o}catch(t){return localStorage.removeItem(e),r}}(S,x,n))),A=d((e=>{if(c(e),D(e),!x)return;if(R.operations.some((e=>"set_selection"!==e.type)))try{const t=JSON.stringify(e);localStorage.setItem(S,t)}catch(e){}}),[x]),C=s((()=>{if(!Array.isArray(r))throw new Error("Props `plugins` should be array of plugins");if(Array.isArray(r)&&0===r.length)throw new Error("Props `plugins` cannot be empty. Pass an array of plugins");const e=Pe(r),t=function(e){const t={};return e.forEach((e=>t[e.type]=e)),t}(e);return{yooptaPlugins:e,PLUGINS_MAP:t}}),[r]),{yooptaPlugins:T,PLUGINS_MAP:H}=C,R=s((()=>{let e=(e=>{const{insertData:t}=e;return e.insertData=n=>{if(!e.selection)return;const r=n.getData("text/html");if(r){const t=rr(r,e.plugins);h.insertFragment(e,t)}else t(n)},e})((e=>{const{deleteFragment:t}=e;return e.deleteFragment=()=>{const{selection:n}=e;if(!n)return;const[,r]=u.first(e,[0]),[,o]=u.last(e,[e.children.length-1]),i=u.range(e,r,o);if(y.equals(n,i))return h.removeNodes(e,{mode:"highest",hanging:!0}),void h.select(e,[0]);t()},e})((e=>{const{normalizeNode:t}=e;return e.normalizeNode=n=>{const[r]=n;if(u.isEditor(r)&&0===e.children.length){const t=tt(Te());h.insertNodes(e,t,{at:[0]})}else t(n)},e})((e=>{const{insertBreak:t,deleteBackward:n}=e;return e.insertBreak=()=>{if(!e.selection||!y.isCollapsed(e.selection))return t();const n=p.parent(e.selection.anchor.path),r=m.get(e,n);g.isElement(r)&&u.isVoid(e,r)?u.insertNode(e,{id:Te(),type:"paragraph",children:[{text:""}],nodeType:"block"}):t()},e.deleteBackward=t=>{if(!e.selection||!y.isCollapsed(e.selection)||0!==e.selection.anchor.offset)return n(t);const r=p.parent(e.selection.anchor.path),o=m.get(e,r);if(0===m.string(o).length&&p.hasPrevious(r)){const t=p.previous(r),n=m.get(e,t);if(g.isElement(n)&&u.isVoid(e,n))return h.removeNodes(e),h.select(e,t)}n(t)},e})((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 r=n[n.length-1];L.withoutSaving(t,(()=>{u.withoutNormalizing(t,(()=>{for(var e of r)t.apply(e)}))})),e.redos.pop(),e.undos.push(r)}},t.undo=()=>{var{history:e}=t,{undos:n}=e;if(n.length>0){var r=n[n.length-1];L.withoutSaving(t,(()=>{u.withoutNormalizing(t,(()=>{var e=r.map(f.inverse).reverse();for(var n of e)t.apply(n)}))})),e.redos.push(r),e.undos.pop()}},t.apply=e=>{var{operations:r,history:o}=t,{undos:i}=o,a=i[i.length-1],s=a&&a[a.length-1],l=F(e,s),c=L.isSaving(t),d=L.isMerging(t);if(null==c&&(c=B(e)),c){if(null==d&&(d=null!=a&&(0!==r.length||M(e,s)||l)),a&&d)l&&a.pop(),a.push(e);else{var u=[e];i.push(u)}for(;i.length>100;)i.shift();z(e)&&(o.redos=[])}n(e)},t})((e=>{const{insertText:t}=e;return e.insertText=n=>{var r,o;const{selection:i}=e;if(" "===n&&i&&y.isCollapsed(i)){const{anchor:a}=i,s=u.above(e,{match:t=>g.isElement(t)&&u.isBlock(e,t),mode:"lowest"});if(!s)return;const[,l]=s,c=u.parent(e,l),[d]=c;if(g.isElement(d)&&!v.isText(d.children[0]))return t(n);const f=s?l:[],p={anchor:a,focus:u.start(e,f)},y=u.string(e,p),m=null===(r=e.shortcuts)||void 0===r?void 0:r[y];if(m)return h.select(e,p),h.delete(e),void(null===(o=m.createElement)||void 0===o||o.call(m,e))}t(n)},e})(E(b())))))));e.plugins=H;const t={};return T.forEach((n=>{var r;n.shortcut&&(Array.isArray(n.shortcut)?n.shortcut.forEach((e=>t[e]=n)):t[n.shortcut]=n),e=(null===(r=n.extendEditor)||void 0===r?void 0:r.call(n,e))||e})),e.shortcuts=t,e}),[T]);return i((()=>{if(O)try{const[,e]=u.first(R,[0]);h.select(R,{anchor:{path:e,offset:0},focus:{path:e,offset:0}}),w.focus(R)}catch(e){}}),[O,R]),e(j,Object.assign({editor:R,initialValue:P,onChange:A},{children:e(it,{children:e(Rt,Object.assign({plugins:T,marks:a,tools:N},{children:e(Mn,{editor:R,readOnly:l,placeholder:_,plugins:T,marks:a,PLUGINS_MAP:H,className:k})}))})}),t)},ir=t=>e(S,{children:e(or,Object.assign({},t,{value:t.value,onChange:t.onChange}))});function ar({type:t,hotkey:n,className:r,as:o}){return Object.freeze({type:t,hotkey:n,render:n=>e(o||"span",Object.assign({},n.attributes,{className:ct(r,`yoopta-leaf-${t}`)},{children:n.children}))})}function sr(e){const{element:t,HTMLAttributes:n,className:r}=e;return`yoopta-${t.type} ${(null==n?void 0:n.className)||""} ${r}`}const lr={ElementOptions:Qt,Overlay:kt};export{Sn as HOTKEYS,lr as UI_HELPERS,Ne as YooptaPlugin,ar as createYooptaMark,Se as createYooptaPlugin,ct as cx,Fe as deepClone,ir as default,Je as disableBodyScroll,Xe as enableBodyScroll,Te as generateId,Dn as getElementByPath,sr as getElementClassname,On as isCodeHotkey,Pn as isElementActive,_n as isHotkey,xn as isKeyHotkey,Le as isValidYooptaNodes,Pe as mergePlugins,Wt as useElements,Vt as useMarks,at as useNodeElementSettings,Ut as useTools,It as useYoopta};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoopta/editor",
3
- "version": "1.9.21-rc",
3
+ "version": "1.9.23-rc",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "type": "module",