@yoopta/embed 1.9.178-rc → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -6,6 +6,6 @@ declare module 'slate' {
6
6
  Element: EmbedElement;
7
7
  }
8
8
  }
9
- declare const Embed: import("@yoopta/editor").YooptaPlugin<EmbedPluginOptions, EmbedElement>;
9
+ declare const Embed: any;
10
10
  export default Embed;
11
11
  export { EmbedElement, EmbedElementData, EmbedPluginOptions };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{getElementClassname as t,UI_HELPERS as e,cx as i,createYooptaPlugin as o,getElementByPath as n,generateId as s}from"@yoopta/editor";import{Transforms as r,Element as a}from"slate";import{jsx as d,jsxs as l}from"react/jsx-runtime";import*as h from"react";import{useState as p,useEffect as c,useRef as u,useMemo as g}from"react";import{flushSync as f}from"react-dom";import{ReactEditor as m,useSelected as v,useReadOnly as b}from"slate-react";function w(t,e){var i={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(i[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(t);n<o.length;n++)e.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(t,o[n])&&(i[o[n]]=t[o[n]])}return i}function y(t,e,i,o){return new(i||(i=Promise))((function(n,s){function r(t){try{d(o.next(t))}catch(t){s(t)}}function a(t){try{d(o.throw(t))}catch(t){s(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}d((o=o.apply(t,e||[])).next())}))}function x(t,{threshold:e=0,root:i=null,rootMargin:o="0%",freezeOnceVisible:n=!1}={}){const[s,r]=p({}),a=s.isIntersecting&&n,d=([t])=>r(t);return c((()=>{const n=null==t?void 0:t.current;if(!window.IntersectionObserver||a||!n)return;const s=new IntersectionObserver(d,{threshold:e,root:i,rootMargin:o});return s.observe(n),()=>s.disconnect()}),[t,e,i,o,a]),s}function z(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&o.firstChild?o.insertBefore(n,o.firstChild):o.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}}"function"==typeof SuppressedError&&SuppressedError;var O="ypSFFbjd",S="DQszzmj7",N="yc58m72J",j="DYsS-Bbu",R="a1CpYHeG";z(".ypSFFbjd{display:flex;height:0;justify-content:center;min-height:100px;padding-bottom:56.25%;position:relative;width:100%}.DQszzmj7{background-color:#fff}.DQszzmj7,.yc58m72J{border-radius:1px;height:100%;pointer-events:auto;width:100%}.DQszzmj7,.DYsS-Bbu,.yc58m72J{left:0;position:absolute;top:0}.DYsS-Bbu{filter:blur(10px);object-fit:cover;transition:opacity .15s ease-in,filter .15s ease-in}.a1CpYHeG{height:100%;position:relative;width:100%}");var E="C8Z8IWw5",W="aGHn-pry",H="-qZtVrzy",C="srCuArtd";function L(t){var{providerId:e,url:i}=t;w(t,["providerId","url"]);const o=u(null),{isIntersecting:n}=x(o,{freezeOnceVisible:!0,rootMargin:"50%"});return d("div",Object.assign({className:E,ref:o},{children:d("div",Object.assign({className:H},{children:d("div",Object.assign({className:C},{children:n&&d("iframe",{src:i,frameBorder:0,allowFullScreen:!0,className:W,height:"450px"})}))}))}))}z(".C8Z8IWw5{display:flex;height:0;justify-content:center;min-height:100px;padding-bottom:56.25%;position:relative;width:100%}.aGHn-pry{background-color:#fff}.-qZtVrzy,.aGHn-pry{border-radius:1px;height:100%;pointer-events:auto;width:100%}.-qZtVrzy,.aGHn-pry,.kmC7RiaF{left:0;position:absolute;top:0}.kmC7RiaF{filter:blur(10px);object-fit:cover;transition:opacity .15s ease-in,filter .15s ease-in}.srCuArtd{height:100%;position:relative;width:100%}");var P="w4l4tKlB",M="cbJcegGv",k="g8V-uGLl",B="j6pRoOC1";z(".w4l4tKlB{display:flex;height:0;justify-content:center;min-height:100px;padding-bottom:56.25%;position:relative;width:100%}.cbJcegGv{background-color:#fff}.cbJcegGv,.g8V-uGLl{border-radius:1px;height:100%;pointer-events:auto;width:100%}.cbJcegGv,.g8V-uGLl,.hZuYZ7vp{left:0;position:absolute;top:0}.hZuYZ7vp{filter:blur(10px);object-fit:cover;transition:opacity .15s ease-in,filter .15s ease-in}.j6pRoOC1{height:100%;position:relative;width:100%}");var I="e3lQDjTT",_="zxjqcq4y",A="ymOgdXs4";z(".e3lQDjTT{display:flex;justify-content:center;min-height:100px;position:relative;width:100%}.O5Z0OWN-{background-color:#fff;position:absolute}.O5Z0OWN-,.zxjqcq4y{border-radius:1px;height:auto;left:0;pointer-events:auto;top:0;width:100%}._5kC3Lf5J{filter:blur(10px);left:0;object-fit:cover;top:0;transition:opacity .15s ease-in,filter .15s ease-in}.ymOgdXs4{position:relative;width:100%}.ymOgdXs4,.ymOgdXs4>div,.ymOgdXs4>div>div{height:auto}");var T="sD5QN14F",V="mRrF4hwM",F="LyyH1fsE",U="U9EPxemn",D="_4AQiBYad";z(".sD5QN14F{display:flex;height:0;justify-content:center;min-height:100px;padding-bottom:56.25%;position:relative;width:100%}.mRrF4hwM{background-color:#fff}.LyyH1fsE,.mRrF4hwM{border-radius:1px;height:100%;pointer-events:auto;width:100%}.LyyH1fsE,.U9EPxemn,.mRrF4hwM{left:0;position:absolute;top:0}.U9EPxemn{filter:blur(10px);object-fit:cover;transition:opacity .15s ease-in,filter .15s ease-in}._4AQiBYad{height:100%;position:relative;width:100%}");var G="zoqyIXwI",Y="WgoSECbO",q="m07CnIxO",J="NSr-cxfm",Z="Cv1rIJbN";z(".zoqyIXwI{display:flex;height:0;justify-content:center;min-height:100px;padding-bottom:56.25%;position:relative;width:100%}.WgoSECbO{background-color:#fff}.WgoSECbO,.m07CnIxO{border-radius:1px;height:100%;pointer-events:auto;width:100%}.NSr-cxfm,.WgoSECbO,.m07CnIxO{left:0;position:absolute;top:0}.NSr-cxfm{filter:blur(10px);object-fit:cover;transition:opacity .15s ease-in,filter .15s ease-in}.Cv1rIJbN{height:100%;position:relative;width:100%}");var Q="HUtGPcJq";z(".HUtGPcJq{margin:20px auto 10px;position:relative}");const X={vimeo:function(t){var{providerId:e}=t,i=w(t,["providerId"]);const o=u(null),[n,s]=p(null),[r,a]=p(!1),{isIntersecting:h}=x(o,{freezeOnceVisible:!0,rootMargin:"50%"});return c((()=>{fetch(`https://vimeo.com/api/v2/video/${e}.json`).then((t=>t.json())).then((t=>s(t[0].thumbnail_medium))).catch((()=>s(null)))}),[e]),d("div",Object.assign({className:T,ref:o},{children:d("div",Object.assign({className:F},{children:l("div",Object.assign({className:D},{children:[d("img",{src:n||"",alt:"vimeo_video_preview",width:"100%",height:"100%",className:U,style:{opacity:h&&r?0:1,zIndex:h&&r?-1:0}}),h&&d("iframe",Object.assign({title:"Vimeo Player",src:`https://player.vimeo.com/video/${e}?badge=0&byline=0&portrait=0&title=0`,frameBorder:0,allowFullScreen:!0,onLoad:()=>a(!0),className:V},i))]}))}))}))},youtube:function(t){var{providerId:e}=t,i=w(t,["providerId"]);const o=u(null),[n,s]=p(!1),{isIntersecting:r}=x(o,{freezeOnceVisible:!0,rootMargin:"50%"});return d("div",Object.assign({className:G,ref:o},{children:d("div",Object.assign({className:q},{children:l("div",Object.assign({className:Z},{children:[d("img",{src:`https://i.ytimg.com/vi/${e}/default.jpg`,alt:"youtube_video_preview",width:"100%",height:"100%",className:J,style:{opacity:r&&n?0:1,zIndex:r&&n?-1:0}}),r&&d("iframe",Object.assign({title:"Youtube Player",src:`https://www.youtube.com/embed/${e}`,frameBorder:0,onLoad:()=>s(!0),allowFullScreen:!0,className:Y},i))]}))}))}))},dailymotion:function(t){var{providerId:e}=t,i=w(t,["providerId"]);const o=u(null),[n,s]=p(null),[r,a]=p(!1),{isIntersecting:h}=x(o,{freezeOnceVisible:!0,rootMargin:"50%"});return c((()=>{fetch((t=>`https://api.dailymotion.com/video/${t}?fields=thumbnail_url`)(e)).then((t=>t.json())).then((t=>s(t.thumbnail_url))).catch((()=>s(null)))}),[e]),d("div",Object.assign({className:O,ref:o},{children:d("div",Object.assign({className:N},{children:l("div",Object.assign({className:R},{children:[d("img",{src:n||"",alt:"daylimotion_video_preview",width:"100%",height:"100%",className:j,style:{opacity:h&&r?0:1,zIndex:h&&r?-1:0}}),h&&d("iframe",Object.assign({title:"Dailymotion Video Player",frameBorder:0,onLoad:()=>a(!0),src:`https://www.dailymotion.com/embed/video/${e}`,allowFullScreen:!0,className:S},i))]}))}))}))},twitter:function({providerId:t}){const e=u(null),{isIntersecting:i}=x(e,{freezeOnceVisible:!0,rootMargin:"50%"});return c((()=>{var o;if(!i)return;const n=document.createElement("script");n.src="https://platform.twitter.com/widgets.js",null===(o=e.current)||void 0===o||o.appendChild(n),n.onload=()=>{window.twttr&&window.twttr.widgets.createTweet(t,document.getElementById(t),{align:"center",conversation:"none",dnt:!0,theme:"dark",height:500})}}),[t,i]),d("div",Object.assign({className:I,ref:e},{children:d("div",Object.assign({className:_},{children:d("div",Object.assign({className:A},{children:d("div",{id:t})}))}))}))},figma:function(t){var{providerId:e,url:i}=t;w(t,["providerId","url"]);const o=u(null),{isIntersecting:n}=x(o,{freezeOnceVisible:!0,rootMargin:"50%"});return d("div",Object.assign({className:P,ref:o},{children:d("div",Object.assign({className:k},{children:d("div",Object.assign({className:B},{children:n&&d("iframe",{src:`https://www.figma.com/embed?embed_host=share&url=${encodeURIComponent(i)}`,frameBorder:0,allowFullScreen:!0,className:M,height:"450px"})}))}))}))}};var $,K,tt=($=function(t,e){return $=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},$(t,e)},function(t,e){function i(){this.constructor=t}$(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),et=function(){return et=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},et.apply(this,arguments)},it={width:"100%",height:"10px",top:"0px",left:"0px",cursor:"row-resize"},ot={width:"10px",height:"100%",top:"0px",left:"0px",cursor:"col-resize"},nt={width:"20px",height:"20px",position:"absolute"},st={top:et(et({},it),{top:"-5px"}),right:et(et({},ot),{left:void 0,right:"-5px"}),bottom:et(et({},it),{top:void 0,bottom:"-5px"}),left:et(et({},ot),{left:"-5px"}),topRight:et(et({},nt),{right:"-10px",top:"-10px",cursor:"ne-resize"}),bottomRight:et(et({},nt),{right:"-10px",bottom:"-10px",cursor:"se-resize"}),bottomLeft:et(et({},nt),{left:"-10px",bottom:"-10px",cursor:"sw-resize"}),topLeft:et(et({},nt),{left:"-10px",top:"-10px",cursor:"nw-resize"})},rt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.onMouseDown=function(t){e.props.onResizeStart(t,e.props.direction)},e.onTouchStart=function(t){e.props.onResizeStart(t,e.props.direction)},e}return tt(e,t),e.prototype.render=function(){return h.createElement("div",{className:this.props.className||"",style:et(et({position:"absolute",userSelect:"none"},st[this.props.direction]),this.props.replaceStyles||{}),onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart},this.props.children)},e}(h.PureComponent),at=function(){var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)};return function(e,i){function o(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}(),dt=function(){return dt=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},dt.apply(this,arguments)},lt={width:"auto",height:"auto"},ht=function(t,e,i){return Math.max(Math.min(t,i),e)},pt=function(t,e){return Math.round(t/e)*e},ct=function(t,e){return new RegExp(t,"i").test(e)},ut=function(t){return Boolean(t.touches&&t.touches.length)},gt=function(t,e,i){void 0===i&&(i=0);var o=e.reduce((function(i,o,n){return Math.abs(o-t)<Math.abs(e[i]-t)?n:i}),0),n=Math.abs(e[o]-t);return 0===i||n<i?e[o]:t},ft=function(t){return"auto"===(t=t.toString())||t.endsWith("px")||t.endsWith("%")||t.endsWith("vh")||t.endsWith("vw")||t.endsWith("vmax")||t.endsWith("vmin")?t:t+"px"},mt=function(t,e,i,o){if(t&&"string"==typeof t){if(t.endsWith("px"))return Number(t.replace("px",""));if(t.endsWith("%"))return e*(Number(t.replace("%",""))/100);if(t.endsWith("vw"))return i*(Number(t.replace("vw",""))/100);if(t.endsWith("vh"))return o*(Number(t.replace("vh",""))/100)}return t},vt=["as","style","className","grid","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],bt="__resizable_base__",wt=function(t){function e(e){var i=t.call(this,e)||this;return i.ratio=1,i.resizable=null,i.parentLeft=0,i.parentTop=0,i.resizableLeft=0,i.resizableRight=0,i.resizableTop=0,i.resizableBottom=0,i.targetLeft=0,i.targetTop=0,i.appendBase=function(){if(!i.resizable||!i.window)return null;var t=i.parentNode;if(!t)return null;var e=i.window.document.createElement("div");return e.style.width="100%",e.style.height="100%",e.style.position="absolute",e.style.transform="scale(0, 0)",e.style.left="0",e.style.flex="0 0 100%",e.classList?e.classList.add(bt):e.className+=bt,t.appendChild(e),e},i.removeBase=function(t){var e=i.parentNode;e&&e.removeChild(t)},i.ref=function(t){t&&(i.resizable=t)},i.state={isResizing:!1,width:void 0===(i.propsSize&&i.propsSize.width)?"auto":i.propsSize&&i.propsSize.width,height:void 0===(i.propsSize&&i.propsSize.height)?"auto":i.propsSize&&i.propsSize.height,direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},i.onResizeStart=i.onResizeStart.bind(i),i.onMouseMove=i.onMouseMove.bind(i),i.onMouseUp=i.onMouseUp.bind(i),i}return at(e,t),Object.defineProperty(e.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"window",{get:function(){return this.resizable&&this.resizable.ownerDocument?this.resizable.ownerDocument.defaultView:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||lt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){var t=0,e=0;if(this.resizable&&this.window){var i=this.resizable.offsetWidth,o=this.resizable.offsetHeight,n=this.resizable.style.position;"relative"!==n&&(this.resizable.style.position="relative"),t="auto"!==this.resizable.style.width?this.resizable.offsetWidth:i,e="auto"!==this.resizable.style.height?this.resizable.offsetHeight:o,this.resizable.style.position=n}return{width:t,height:e}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sizeStyle",{get:function(){var t=this,e=this.props.size,i=function(e){if(void 0===t.state[e]||"auto"===t.state[e])return"auto";if(t.propsSize&&t.propsSize[e]&&t.propsSize[e].toString().endsWith("%")){if(t.state[e].toString().endsWith("%"))return t.state[e].toString();var i=t.getParentSize();return Number(t.state[e].toString().replace("px",""))/i[e]*100+"%"}return ft(t.state[e])};return{width:e&&void 0!==e.width&&!this.state.isResizing?ft(e.width):i("width"),height:e&&void 0!==e.height&&!this.state.isResizing?ft(e.height):i("height")}},enumerable:!1,configurable:!0}),e.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var t=this.appendBase();if(!t)return{width:0,height:0};var e=!1,i=this.parentNode.style.flexWrap;"wrap"!==i&&(e=!0,this.parentNode.style.flexWrap="wrap"),t.style.position="relative",t.style.minWidth="100%",t.style.minHeight="100%";var o={width:t.offsetWidth,height:t.offsetHeight};return e&&(this.parentNode.style.flexWrap=i),this.removeBase(t),o},e.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},e.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},e.prototype.componentDidMount=function(){if(this.resizable&&this.window){var t=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:"auto"!==t.flexBasis?t.flexBasis:void 0})}},e.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},e.prototype.createSizeForCssProperty=function(t,e){var i=this.propsSize&&this.propsSize[e];return"auto"!==this.state[e]||this.state.original[e]!==t||void 0!==i&&"auto"!==i?t:"auto"},e.prototype.calculateNewMaxFromBoundary=function(t,e){var i,o,n=this.props.boundsByDirection,s=this.state.direction,r=n&&ct("left",s),a=n&&ct("top",s);if("parent"===this.props.bounds){var d=this.parentNode;d&&(i=r?this.resizableRight-this.parentLeft:d.offsetWidth+(this.parentLeft-this.resizableLeft),o=a?this.resizableBottom-this.parentTop:d.offsetHeight+(this.parentTop-this.resizableTop))}else"window"===this.props.bounds?this.window&&(i=r?this.resizableRight:this.window.innerWidth-this.resizableLeft,o=a?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(i=r?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),o=a?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return i&&Number.isFinite(i)&&(t=t&&t<i?t:i),o&&Number.isFinite(o)&&(e=e&&e<o?e:o),{maxWidth:t,maxHeight:e}},e.prototype.calculateNewSizeFromDirection=function(t,e){var i=this.props.scale||1,o=this.props.resizeRatio||1,n=this.state,s=n.direction,r=n.original,a=this.props,d=a.lockAspectRatio,l=a.lockAspectRatioExtraHeight,h=a.lockAspectRatioExtraWidth,p=r.width,c=r.height,u=l||0,g=h||0;return ct("right",s)&&(p=r.width+(t-r.x)*o/i,d&&(c=(p-g)/this.ratio+u)),ct("left",s)&&(p=r.width-(t-r.x)*o/i,d&&(c=(p-g)/this.ratio+u)),ct("bottom",s)&&(c=r.height+(e-r.y)*o/i,d&&(p=(c-u)*this.ratio+g)),ct("top",s)&&(c=r.height-(e-r.y)*o/i,d&&(p=(c-u)*this.ratio+g)),{newWidth:p,newHeight:c}},e.prototype.calculateNewSizeFromAspectRatio=function(t,e,i,o){var n=this.props,s=n.lockAspectRatio,r=n.lockAspectRatioExtraHeight,a=n.lockAspectRatioExtraWidth,d=void 0===o.width?10:o.width,l=void 0===i.width||i.width<0?t:i.width,h=void 0===o.height?10:o.height,p=void 0===i.height||i.height<0?e:i.height,c=r||0,u=a||0;if(s){var g=(h-c)*this.ratio+u,f=(p-c)*this.ratio+u,m=(d-u)/this.ratio+c,v=(l-u)/this.ratio+c,b=Math.max(d,g),w=Math.min(l,f),y=Math.max(h,m),x=Math.min(p,v);t=ht(t,b,w),e=ht(e,y,x)}else t=ht(t,d,l),e=ht(e,h,p);return{newWidth:t,newHeight:e}},e.prototype.setBoundingClientRect=function(){if("parent"===this.props.bounds){var t=this.parentNode;if(t){var e=t.getBoundingClientRect();this.parentLeft=e.left,this.parentTop=e.top}}if(this.props.bounds&&"string"!=typeof this.props.bounds){var i=this.props.bounds.getBoundingClientRect();this.targetLeft=i.left,this.targetTop=i.top}if(this.resizable){var o=this.resizable.getBoundingClientRect(),n=o.left,s=o.top,r=o.right,a=o.bottom;this.resizableLeft=n,this.resizableRight=r,this.resizableTop=s,this.resizableBottom=a}},e.prototype.onResizeStart=function(t,e){if(this.resizable&&this.window){var i,o=0,n=0;if(t.nativeEvent&&function(t){return Boolean((t.clientX||0===t.clientX)&&(t.clientY||0===t.clientY))}(t.nativeEvent)?(o=t.nativeEvent.clientX,n=t.nativeEvent.clientY):t.nativeEvent&&ut(t.nativeEvent)&&(o=t.nativeEvent.touches[0].clientX,n=t.nativeEvent.touches[0].clientY),this.props.onResizeStart)if(this.resizable)if(!1===this.props.onResizeStart(t,e,this.resizable))return;this.props.size&&(void 0!==this.props.size.height&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),void 0!==this.props.size.width&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio="number"==typeof this.props.lockAspectRatio?this.props.lockAspectRatio:this.size.width/this.size.height;var s=this.window.getComputedStyle(this.resizable);if("auto"!==s.flexBasis){var r=this.parentNode;if(r){var a=this.window.getComputedStyle(r).flexDirection;this.flexDir=a.startsWith("row")?"row":"column",i=s.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var d={original:{x:o,y:n,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:dt(dt({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(t.target).cursor||"auto"}),direction:e,flexBasis:i};this.setState(d)}},e.prototype.onMouseMove=function(t){var e=this;if(this.state.isResizing&&this.resizable&&this.window){if(this.window.TouchEvent&&ut(t))try{t.preventDefault(),t.stopPropagation()}catch(t){}var i=this.props,o=i.maxWidth,n=i.maxHeight,s=i.minWidth,r=i.minHeight,a=ut(t)?t.touches[0].clientX:t.clientX,d=ut(t)?t.touches[0].clientY:t.clientY,l=this.state,h=l.direction,p=l.original,c=l.width,u=l.height,g=this.getParentSize(),m=function(t,e,i,o,n,s,r){return o=mt(o,t.width,e,i),n=mt(n,t.height,e,i),s=mt(s,t.width,e,i),r=mt(r,t.height,e,i),{maxWidth:void 0===o?void 0:Number(o),maxHeight:void 0===n?void 0:Number(n),minWidth:void 0===s?void 0:Number(s),minHeight:void 0===r?void 0:Number(r)}}(g,this.window.innerWidth,this.window.innerHeight,o,n,s,r);o=m.maxWidth,n=m.maxHeight,s=m.minWidth,r=m.minHeight;var v=this.calculateNewSizeFromDirection(a,d),b=v.newHeight,w=v.newWidth,y=this.calculateNewMaxFromBoundary(o,n);this.props.snap&&this.props.snap.x&&(w=gt(w,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(b=gt(b,this.props.snap.y,this.props.snapGap));var x=this.calculateNewSizeFromAspectRatio(w,b,{width:y.maxWidth,height:y.maxHeight},{width:s,height:r});if(w=x.newWidth,b=x.newHeight,this.props.grid){var z=pt(w,this.props.grid[0]),O=pt(b,this.props.grid[1]),S=this.props.snapGap||0;w=0===S||Math.abs(z-w)<=S?z:w,b=0===S||Math.abs(O-b)<=S?O:b}var N={width:w-p.width,height:b-p.height};if(c&&"string"==typeof c)if(c.endsWith("%"))w=w/g.width*100+"%";else if(c.endsWith("vw")){w=w/this.window.innerWidth*100+"vw"}else if(c.endsWith("vh")){w=w/this.window.innerHeight*100+"vh"}if(u&&"string"==typeof u)if(u.endsWith("%"))b=b/g.height*100+"%";else if(u.endsWith("vw")){b=b/this.window.innerWidth*100+"vw"}else if(u.endsWith("vh")){b=b/this.window.innerHeight*100+"vh"}var j={width:this.createSizeForCssProperty(w,"width"),height:this.createSizeForCssProperty(b,"height")};"row"===this.flexDir?j.flexBasis=j.width:"column"===this.flexDir&&(j.flexBasis=j.height),f((function(){e.setState(j)})),this.props.onResize&&this.props.onResize(t,h,this.resizable,N)}},e.prototype.onMouseUp=function(t){var e=this.state,i=e.isResizing,o=e.direction,n=e.original;if(i&&this.resizable){var s={width:this.size.width-n.width,height:this.size.height-n.height};this.props.onResizeStop&&this.props.onResizeStop(t,o,this.resizable,s),this.props.size&&this.setState(this.props.size),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:dt(dt({},this.state.backgroundStyle),{cursor:"auto"})})}},e.prototype.updateSize=function(t){this.setState({width:t.width,height:t.height})},e.prototype.renderResizer=function(){var t=this,e=this.props,i=e.enable,o=e.handleStyles,n=e.handleClasses,s=e.handleWrapperStyle,r=e.handleWrapperClass,a=e.handleComponent;if(!i)return null;var d=Object.keys(i).map((function(e){return!1!==i[e]?h.createElement(rt,{key:e,direction:e,onResizeStart:t.onResizeStart,replaceStyles:o&&o[e],className:n&&n[e]},a&&a[e]?a[e]:null):null}));return h.createElement("div",{className:r,style:s},d)},e.prototype.render=function(){var t=this,e=Object.keys(this.props).reduce((function(e,i){return-1!==vt.indexOf(i)||(e[i]=t.props[i]),e}),{}),i=dt(dt(dt({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(i.flexBasis=this.state.flexBasis);var o=this.props.as||"div";return h.createElement(o,dt({ref:this.ref,style:i,className:this.props.className},e),this.state.isResizing&&h.createElement("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer())},e.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},e}(h.PureComponent);function yt(){return yt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o])}return t},yt.apply(this,arguments)}var xt=function(t){return h.createElement("svg",yt({fill:"currentColor","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"uploadImage"},t),K||(K=h.createElement("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"})))},zt="_5ZnGUwAU",Ot="wlwFaZpx",St="Obm15-qh",Nt="gJ5-oVLV",jt="_6jUel99o",Rt="HZgHUcV-",Et="GF1PbH1g gU1gU-Wq",Wt="i7UwLauz",Ht="cJSOiHYH";z('._5ZnGUwAU{position:fixed}.wlwFaZpx{background:#fff;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:100%;max-height:420px;max-width:calc(100vw - 24px);min-width:540px}.Obm15-qh{box-shadow:inset 0 -1px 0 rgba(55,53,47,.09);display:flex;height:40px;padding:0 8px;width:100%;z-index:1}.Obm15-qh,.gJ5-oVLV{font-size:14px;position:relative}.gJ5-oVLV{align-items:center;background-color:inherit;border:none;border-radius:4px;color:#37352f;cursor:pointer;display:inline-flex;flex-shrink:0;height:100%;line-height:1.2;min-width:0;padding:6px 8px;transition:height 20ms ease-in 0s;user-select:none;white-space:nowrap}._6jUel99o:after{background-color:#37352f;bottom:0;content:"";height:2px;left:0;position:absolute;width:100%}.HZgHUcV-{display:flex;justify-content:center;margin-left:12px;margin-right:12px;margin-top:4px;padding-bottom:6px;padding-top:6px}.gU1gU-Wq{border:1px solid rgba(55,53,47,.16);border-radius:4px;cursor:pointer;height:32px;padding-left:12px;padding-right:12px;transition:background 20ms ease-in 0s;user-select:none;white-space:nowrap;width:100%}.GF1PbH1g{border:none!important;cursor:pointer!important;height:auto!important;padding-left:0!important;padding-right:0!important}.i2lz5EKx{align-items:center;cursor:pointer;display:inline-flex;font-size:14px;font-weight:500;height:100%;justify-content:center;line-height:1.2;width:100%}._3cPFLttW{left:0;position:absolute;top:0;visibility:hidden}.i7UwLauz{background:hsla(45,13%,94%,.6);box-shadow:inset 0 0 0 1px hsla(0,0%,6%,.1);cursor:text;height:32px;line-height:20px;padding:3px 6px;position:relative}.cJSOiHYH,.i7UwLauz{align-items:center;border:none;border-radius:4px;display:flex;font-size:14px;width:100%}.cJSOiHYH{fill:#fff;background:#2383e2;box-shadow:inset 0 0 0 1px hsla(0,0%,6%,.1),0 1px 2px hsla(0,0%,6%,.1);color:#fff;cursor:pointer;flex-shrink:0;font-weight:500;height:28px;justify-content:center;line-height:1.2;margin:12px auto 6px;max-width:300px;padding-left:12px;padding-right:12px;transition:background 20ms ease-in 0s;user-select:none;white-space:nowrap}');const Ct=({onEmbed:t})=>{const[e,i]=p("");return l("div",Object.assign({className:Et},{children:[d("input",{type:"text",placeholder:"Paste embed link",value:e,className:Wt,onChange:t=>i(t.target.value)}),d("button",Object.assign({type:"button",className:Ht,onClick:()=>t(e)},{children:"Embed"}))]}))},Lt=({style:t,onEmbed:o,onClose:n})=>l(e.Overlay,Object.assign({onClose:n},{children:[d("div",Object.assign({className:zt,style:t},{children:l("div",Object.assign({className:Ot},{children:[d("div",Object.assign({className:St},{children:d("button",Object.assign({type:"button",className:i(Nt,{[jt]:!0})},{children:"Embed link"}))})),d("div",Object.assign({className:Rt},{children:d(Ct,{onEmbed:o})}))]}))})),d("div",{})]}));var Pt=!1;if("undefined"!=typeof window){var Mt={get passive(){Pt=!0}};window.addEventListener("testPassive",null,Mt),window.removeEventListener("testPassive",null,Mt)}var kt="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),Bt=[],It=!1,_t=-1,At=void 0,Tt=void 0,Vt=void 0,Ft=function(t){return Bt.some((function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(t))}))},Ut=function(t){var e=t||window.event;return!!Ft(e.target)||(e.touches.length>1||(e.preventDefault&&e.preventDefault(),!1))},Dt=function(t,e){if(t){if(!Bt.some((function(e){return e.targetElement===t}))){var i={targetElement:t,options:e||{}};Bt=[].concat(function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}(Bt),[i]),kt?window.requestAnimationFrame((function(){if(void 0===Tt){Tt={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var t=window,e=t.scrollY,i=t.scrollX,o=t.innerHeight;document.body.style.position="fixed",document.body.style.top=-e,document.body.style.left=-i,setTimeout((function(){return window.requestAnimationFrame((function(){var t=o-window.innerHeight;t&&e>=o&&(document.body.style.top=-(e+t))}))}),300)}})):function(t){if(void 0===Vt){var e=!!t&&!0===t.reserveScrollBarGap,i=window.innerWidth-document.documentElement.clientWidth;if(e&&i>0){var o=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);Vt=document.body.style.paddingRight,document.body.style.paddingRight=o+i+"px"}}void 0===At&&(At=document.body.style.overflow,document.body.style.overflow="hidden")}(e),kt&&(t.ontouchstart=function(t){1===t.targetTouches.length&&(_t=t.targetTouches[0].clientY)},t.ontouchmove=function(e){1===e.targetTouches.length&&function(t,e){var i=t.targetTouches[0].clientY-_t;!Ft(t.target)&&(e&&0===e.scrollTop&&i>0||function(t){return!!t&&t.scrollHeight-t.scrollTop<=t.clientHeight}(e)&&i<0?Ut(t):t.stopPropagation())}(e,t)},It||(document.addEventListener("touchmove",Ut,Pt?{passive:!1}:void 0),It=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},Gt=function(t){t?(Bt=Bt.filter((function(e){return e.targetElement!==t})),kt&&(t.ontouchstart=null,t.ontouchmove=null,It&&0===Bt.length&&(document.removeEventListener("touchmove",Ut,Pt?{passive:!1}:void 0),It=!1)),kt?function(){if(void 0!==Tt){var t=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=Tt.position,document.body.style.top=Tt.top,document.body.style.left=Tt.left,window.scrollTo(e,t),Tt=void 0}}():(void 0!==Vt&&(document.body.style.paddingRight=Vt,Vt=void 0),void 0!==At&&(document.body.style.overflow=At,At=void 0))):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")},Yt="PoOhS4FU",qt="PcGiiPpV",Jt="iQZH4Lf-";z(".PoOhS4FU{margin:20px 0 10px;user-select:none}.PcGiiPpV,.PoOhS4FU{position:relative;width:100%}.PcGiiPpV{align-items:center;background-color:#efefef;border:none;border-radius:3px;color:rgba(55,53,47,.65);cursor:pointer;display:flex;font-size:14px;overflow:hidden;padding:12px 36px 12px 12px;text-align:left;transition:background-color .1s ease-in}.PcGiiPpV:hover{background-color:#e3e3e3}.iQZH4Lf-{margin-right:8px;user-select:none}");const Zt=({element:t,attributes:e,maxSizes:i,children:o,editor:n})=>{const[s,h]=p(null),c=u(null),g=t=>{var e;if(t.stopPropagation(),null!==s)return Gt(document.body),void h(null);const i=null===(e=c.current)||void 0===e?void 0:e.getBoundingClientRect();if(i){const t=i.top+i.height+88+20>window.innerHeight,e=!t;console.log({showAtTop:t,showAtBottom:e}),Dt(document.body,{reserveScrollBarGap:!0}),h({left:i.left,top:t?i.top-88-5:i.top+i.height+5})}};return l("div",Object.assign({className:Yt},e,{contentEditable:!1},{children:[l("div",Object.assign({ref:c},{children:[l("button",Object.assign({className:qt,onClick:g},{children:[d(xt,{className:Jt,width:24,height:24}),d("span",{children:"Click to add embed"})]})),null!==s&&d(Lt,{onEmbed:e=>y(void 0,void 0,void 0,(function*(){if(0===e.length)return;const i=(o=e).includes("youtube.com")||o.includes("youtu.be")?"youtube":o.includes("vimeo.com")?"vimeo":o.includes("dailymotion.com")||o.includes("dai.ly")?"dailymotion":o.includes("twitter")?"twitter":o.includes("figma")?"figma":null;var o;let s=null;"youtube"===i?s=(t=>{const e=t.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/);return e&&11===e[2].length?e[2]:null})(e):"vimeo"===i?s=(t=>new URL(t).pathname.split("/")[1])(e):"dailymotion"===i?s=(t=>{var e=t.match(/^.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/);return null!==e?void 0!==e[4]?e[4]:e[2]:null})(e):"twitter"===i?s=function(t){const e=t.match(/\/status\/(\d+)/);return e?e[1]:null}(e):"figma"===i&&(s=function(t){const e=new URL(t).searchParams,i=e.get("node-id");return e.get("node-id")?i:"unknown"}(e)),console.log({provider:i,providerId:s,path:m.findPath(n,t),element:t});try{Gt(document.body),h(null);const o={data:Object.assign(Object.assign({},t.data),{url:e,size:{width:t.data.size.width,height:t.data.size.height},provider:i,providerId:s})};r.setNodes(n,o,{at:m.findPath(n,t),match:t=>a.isElement(t)&&"embed"===t.type})}catch(t){console.log("provider adding error",t),Gt(document.body),h(null)}})),onClose:g,style:s})]})),o]}))};var Qt="s8SlWwrL",Xt="_5qhGnBQW",$t="_6GzVi0JR",Kt="HLz36qUX OLRmQVp3",te="Tv1Fs118 OLRmQVp3",ee="_33V0MBSa",ie="VdsHNo29",oe="WARAR91D",ne="_92ciCRYx";z(".s8SlWwrL{cursor:pointer;display:block;position:relative}.s8SlWwrL:hover .OLRmQVp3,.s8SlWwrL:hover ._5qhGnBQW{opacity:1}._0z3X-ysz{pointer-events:none}._9GorNz7R{margin:20px 0 30px}._6GzVi0JR{margin:0 auto}.OLRmQVp3{align-items:center;cursor:col-resize;display:flex;height:100%;justify-content:center;opacity:0;pointer-events:none;position:absolute;transition:opacity .15s ease-in 0s;width:15px;z-index:1}.HLz36qUX{left:0;top:0}.Tv1Fs118{right:0;top:0}._33V0MBSa{background:hsla(0,0%,6%,.6);border:1px solid hsla(0,0%,100%,.9);border-radius:20px;box-shadow:0 0 0 .5px #fff;height:48px;max-height:50%;opacity:1;transition:opacity .3s ease-in 0s;width:6px}.VdsHNo29{opacity:0}.WARAR91D{background:rgba(35,131,226,.14);border-radius:3px;inset:0;opacity:1;pointer-events:none;position:absolute;transition:opacity .15s ease-in 0s;z-index:81}._8VNstZwX{left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}._5qhGnBQW{align-items:center;background-color:#eee;border:none;border-radius:2px;cursor:pointer;display:flex;height:22px;justify-content:space-between;opacity:0;padding:0 4px;position:absolute;right:10px;top:10px;transition:opacity .15s ease-in 0s;width:22px;z-index:1}._92ciCRYx{background-color:gray;border-radius:50%;min-height:3px;min-width:3px}");function se(t){var o,n,s,h,u;const{element:f,editor:w,plugin:y}=t,x=v(),z=b(),[O,S]=p(null),[N,j]=p({width:(null===(n=null===(o=f.data)||void 0===o?void 0:o.size)||void 0===n?void 0:n.width)||750,height:(null===(h=null===(s=f.data)||void 0===s?void 0:s.size)||void 0===h?void 0:h.height)||440}),R=t=>j(Object.assign(Object.assign({},N),t));c((()=>{var t,e,i,o;f.data&&R({width:(null===(e=null===(t=f.data)||void 0===t?void 0:t.size)||void 0===e?void 0:e.width)||750,height:(null===(o=null===(i=f.data)||void 0===i?void 0:i.size)||void 0===o?void 0:o.height)||440})}),[null===(u=f.data)||void 0===u?void 0:u.size]);const E=g((()=>{var t,e;return{minWidth:300,size:{width:N.width,height:N.height},maxWidth:(null===(t=y.options)||void 0===t?void 0:t.maxWidth)||800,maxHeight:(null===(e=y.options)||void 0===e?void 0:e.maxHeight)||720,lockAspectRatio:!0,resizeRatio:2,enable:{left:!z,right:!z},handleStyles:{left:{left:0},right:{right:0}},onResize:(t,e,i)=>{R({width:i.offsetWidth,height:i.offsetHeight})},onResizeStop:(t,e,i)=>{console.log("image editor editor.children",w.children),console.log("ReactEditor.findPath(editor, element)",m.findPath(w,f)),console.log("element",f),r.setNodes(w,{data:Object.assign(Object.assign({},f.data),{size:{width:i.offsetWidth,height:i.offsetHeight}})},{at:m.findPath(w,f),match:t=>a.isElement(t)&&"embed"===t.type})},handleComponent:{left:d("div",Object.assign({contentEditable:!1,className:Kt},{children:d("div",{className:ee})})),right:d("div",Object.assign({contentEditable:!1,className:te},{children:d("div",{className:ee})}))}}}),[N.width,N.height,w]),W=()=>{Gt(document.body),S(null)},H=t=>{var e;if(null==t||t.stopPropagation(),null!==O)return W();const i=null===(e=null==t?void 0:t.currentTarget)||void 0===e?void 0:e.getBoundingClientRect();if(i){const t=i.top+i.height+164+20>window.innerHeight;Dt(document.body,{reserveScrollBarGap:!0}),S({left:i.right-i.width+265>window.innerWidth?window.innerWidth-265-i.width:i.right-i.width,top:t?i.top-82-i.height:i.top+i.height+5})}};if(!f.data.url&&!f.data["data-src"]){const{maxWidth:o=750,maxHeight:n=800}=y.options||{};return l("div",Object.assign({className:Qt,contentEditable:!1,draggable:!1},{children:[d("div",{className:i(ie,{[oe]:x})}),d(Zt,Object.assign({attributes:t.attributes,element:f,editor:w,maxSizes:{maxWidth:o,maxHeight:n}},{children:!z&&l("div",{children:[l("button",Object.assign({type:"button",className:Xt,onClick:H},{children:[d("span",{className:ne}),d("span",{className:ne}),d("span",{className:ne})]})),null!==O&&d(e.ElementOptions,{onClose:W,style:O,element:f,onCopy:W,onDelete:W,onDuplicate:W},f.id)]})})),t.children]}),f.id)}return d("div",Object.assign({contentEditable:!1,draggable:!1,className:Qt},{children:l(wt,Object.assign({},E,{className:$t},{children:[y.renderer.render(Object.assign(Object.assign({},t),{size:N,isEdit:!0})),d("div",{className:i(ie,{[oe]:x})}),!z&&l("div",{children:[l("button",Object.assign({type:"button",className:Xt,onClick:H},{children:[d("span",{className:ne}),d("span",{className:ne}),d("span",{className:ne})]})),null!==O&&d(e.ElementOptions,{onClose:W,style:O,element:f,onCopy:W,onDelete:W,onDuplicate:W},f.id)]})]}))}),f.id)}const re=o({type:"embed",shortcut:"embed",renderer:{editor:(t,e)=>i=>d(se,Object.assign({editor:t,plugin:e},i)),render:({attributes:e,element:i,children:o,HTMLAttributes:n,isEdit:s=!1})=>{if("string"==typeof i.data.provider&&i.data.providerId&&X[i.data.provider]){const r=X[i.data.provider];return l("div",Object.assign({},e,{contentEditable:!1,draggable:!1},n,{style:s?void 0:i.data.size,className:t({element:i,HTMLAttributes:n,className:Q})},{children:[d(r,Object.assign({},i.data,{providerId:i.data.providerId})),o]}))}return i.data.url?l("div",Object.assign({},e,{contentEditable:!1,draggable:!1},n,{className:t({element:i,HTMLAttributes:n,className:Q}),style:s?void 0:i.data.size},{children:[d(L,Object.assign({},i.data,{providerId:i.data.providerId})),o]})):d("div",{})}},extendEditor(t){const{isVoid:e}=t;return t.isVoid=t=>t.type===re.getPlugin.type||e(t),t},events:{onKeyDown:(t,{defaultNode:e,hotkeys:i})=>o=>{var s;if("embed"===n(t,null===(s=t.selection)||void 0===s?void 0:s.anchor.path,"highest").type&&t.selection)return i.isEnter(o)?(o.preventDefault(),void r.insertNodes(t,e,{mode:"highest"})):void 0}},defineElement:()=>({id:s(),type:"embed",nodeType:"void",data:{url:null,size:{width:"auto",height:"auto"},providerId:null},children:[{text:""}]}),createElement:(t,e)=>{var i;const o=Object.assign(Object.assign({},re.getPlugin.defineElement()),e);r.setNodes(t,o,{at:null===(i=t.selection)||void 0===i?void 0:i.anchor})},exports:{markdown:{serialize:(t,e)=>`[embed-url](${t.data.url})\n`},html:{serialize:(t,e)=>{var i,o;return`<iframe src="https://player.vimeo.com/video/807053663?badge=0&amp;byline=0&amp;portrait=0&amp;title=0" frameborder="0" height="${null===(i=t.data.size)||void 0===i?void 0:i.height}" width="${null===(o=t.data.size)||void 0===o?void 0:o.width}" allowfullscreen="" url="https://vimeo.com/807053663" provider="${t.data.provider||""}" />`},deserialize:{nodeName:"IFRAME",parse:t=>({url:t.getAttribute("src"),size:{height:"string"==typeof t.getAttribute("height")?Number(t.getAttribute("height")):"auto",width:"string"==typeof t.getAttribute("width")?Number(t.getAttribute("width")):"auto"}})}}},options:{searchString:"Embed media",displayLabel:"Embed"}});export{re as default};
1
+ import{getElementClassname as t,UI_HELPERS as e,cx as i,createYooptaPlugin as o,getElementByPath as n,generateId as s}from"@yoopta/editor";import{Transforms as r,Element as a}from"slate";import{jsx as l,jsxs as d}from"react/jsx-runtime";import*as h from"react";import{useState as p,useEffect as c,useRef as u,useMemo as g}from"react";import{flushSync as f}from"react-dom";import{ReactEditor as m,useSelected as v,useReadOnly as b}from"slate-react";function w(t,e){var i={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(i[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(t);n<o.length;n++)e.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(t,o[n])&&(i[o[n]]=t[o[n]])}return i}function y(t,e,i,o){return new(i||(i=Promise))((function(n,s){function r(t){try{l(o.next(t))}catch(t){s(t)}}function a(t){try{l(o.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}l((o=o.apply(t,e||[])).next())}))}function x(t,{threshold:e=0,root:i=null,rootMargin:o="0%",freezeOnceVisible:n=!1}={}){const[s,r]=p({}),a=s.isIntersecting&&n,l=([t])=>r(t);return c((()=>{const n=null==t?void 0:t.current;if(!window.IntersectionObserver||a||!n)return;const s=new IntersectionObserver(l,{threshold:e,root:i,rootMargin:o});return s.observe(n),()=>s.disconnect()}),[t,e,i,o,a]),s}function z(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&o.firstChild?o.insertBefore(n,o.firstChild):o.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}}"function"==typeof SuppressedError&&SuppressedError;var O="ypSFFbjd",S="DQszzmj7",N="yc58m72J",j="DYsS-Bbu",R="a1CpYHeG";z(".ypSFFbjd{display:flex;height:0;justify-content:center;min-height:100px;padding-bottom:56.25%;position:relative;width:100%}.DQszzmj7{background-color:#fff}.DQszzmj7,.yc58m72J{border-radius:1px;height:100%;pointer-events:auto;width:100%}.DQszzmj7,.DYsS-Bbu,.yc58m72J{left:0;position:absolute;top:0}.DYsS-Bbu{filter:blur(10px);object-fit:cover;transition:opacity .15s ease-in,filter .15s ease-in}.a1CpYHeG{height:100%;position:relative;width:100%}");var E="C8Z8IWw5",W="aGHn-pry",H="-qZtVrzy",C="srCuArtd";function L(t){var{providerId:e,url:i}=t;w(t,["providerId","url"]);const o=u(null),{isIntersecting:n}=x(o,{freezeOnceVisible:!0,rootMargin:"50%"});return l("div",Object.assign({className:E,ref:o},{children:l("div",Object.assign({className:H},{children:l("div",Object.assign({className:C},{children:n&&l("iframe",{src:i,frameBorder:0,allowFullScreen:!0,className:W,height:"450px"})}))}))}))}z(".C8Z8IWw5{display:flex;height:0;justify-content:center;min-height:100px;padding-bottom:56.25%;position:relative;width:100%}.aGHn-pry{background-color:#fff}.-qZtVrzy,.aGHn-pry{border-radius:1px;height:100%;pointer-events:auto;width:100%}.-qZtVrzy,.aGHn-pry,.kmC7RiaF{left:0;position:absolute;top:0}.kmC7RiaF{filter:blur(10px);object-fit:cover;transition:opacity .15s ease-in,filter .15s ease-in}.srCuArtd{height:100%;position:relative;width:100%}");var P="w4l4tKlB",M="cbJcegGv",k="g8V-uGLl",B="j6pRoOC1";z(".w4l4tKlB{display:flex;height:0;justify-content:center;min-height:100px;padding-bottom:56.25%;position:relative;width:100%}.cbJcegGv{background-color:#fff}.cbJcegGv,.g8V-uGLl{border-radius:1px;height:100%;pointer-events:auto;width:100%}.cbJcegGv,.g8V-uGLl,.hZuYZ7vp{left:0;position:absolute;top:0}.hZuYZ7vp{filter:blur(10px);object-fit:cover;transition:opacity .15s ease-in,filter .15s ease-in}.j6pRoOC1{height:100%;position:relative;width:100%}");var I="e3lQDjTT",_="zxjqcq4y",A="ymOgdXs4";z(".e3lQDjTT{display:flex;justify-content:center;min-height:100px;position:relative;width:100%}.O5Z0OWN-{background-color:#fff;position:absolute}.O5Z0OWN-,.zxjqcq4y{border-radius:1px;height:auto;left:0;pointer-events:auto;top:0;width:100%}._5kC3Lf5J{filter:blur(10px);left:0;object-fit:cover;top:0;transition:opacity .15s ease-in,filter .15s ease-in}.ymOgdXs4{position:relative;width:100%}.ymOgdXs4,.ymOgdXs4>div,.ymOgdXs4>div>div{height:auto}");var T="sD5QN14F",V="mRrF4hwM",F="LyyH1fsE",U="U9EPxemn",D="_4AQiBYad";z(".sD5QN14F{display:flex;height:0;justify-content:center;min-height:100px;padding-bottom:56.25%;position:relative;width:100%}.mRrF4hwM{background-color:#fff}.LyyH1fsE,.mRrF4hwM{border-radius:1px;height:100%;pointer-events:auto;width:100%}.LyyH1fsE,.U9EPxemn,.mRrF4hwM{left:0;position:absolute;top:0}.U9EPxemn{filter:blur(10px);object-fit:cover;transition:opacity .15s ease-in,filter .15s ease-in}._4AQiBYad{height:100%;position:relative;width:100%}");var G="zoqyIXwI",Y="WgoSECbO",q="m07CnIxO",J="NSr-cxfm",Z="Cv1rIJbN";z(".zoqyIXwI{display:flex;height:0;justify-content:center;min-height:100px;padding-bottom:56.25%;position:relative;width:100%}.WgoSECbO{background-color:#fff}.WgoSECbO,.m07CnIxO{border-radius:1px;height:100%;pointer-events:auto;width:100%}.NSr-cxfm,.WgoSECbO,.m07CnIxO{left:0;position:absolute;top:0}.NSr-cxfm{filter:blur(10px);object-fit:cover;transition:opacity .15s ease-in,filter .15s ease-in}.Cv1rIJbN{height:100%;position:relative;width:100%}");var Q="HUtGPcJq";z(".HUtGPcJq{margin:20px auto 10px;position:relative}");const X={vimeo:function(t){var{providerId:e}=t,i=w(t,["providerId"]);const o=u(null),[n,s]=p(null),[r,a]=p(!1),{isIntersecting:h}=x(o,{freezeOnceVisible:!0,rootMargin:"50%"});return c((()=>{fetch(`https://vimeo.com/api/v2/video/${e}.json`).then((t=>t.json())).then((t=>s(t[0].thumbnail_medium))).catch((()=>s(null)))}),[e]),l("div",Object.assign({className:T,ref:o},{children:l("div",Object.assign({className:F},{children:d("div",Object.assign({className:D},{children:[l("img",{src:n||"",alt:"vimeo_video_preview",width:"100%",height:"100%",className:U,style:{opacity:h&&r?0:1,zIndex:h&&r?-1:0}}),h&&l("iframe",Object.assign({title:"Vimeo Player",src:`https://player.vimeo.com/video/${e}?badge=0&byline=0&portrait=0&title=0`,frameBorder:0,allowFullScreen:!0,onLoad:()=>a(!0),className:V},i))]}))}))}))},youtube:function(t){var{providerId:e}=t,i=w(t,["providerId"]);const o=u(null),[n,s]=p(!1),{isIntersecting:r}=x(o,{freezeOnceVisible:!0,rootMargin:"50%"});return l("div",Object.assign({className:G,ref:o},{children:l("div",Object.assign({className:q},{children:d("div",Object.assign({className:Z},{children:[l("img",{src:`https://i.ytimg.com/vi/${e}/default.jpg`,alt:"youtube_video_preview",width:"100%",height:"100%",className:J,style:{opacity:r&&n?0:1,zIndex:r&&n?-1:0}}),r&&l("iframe",Object.assign({title:"Youtube Player",src:`https://www.youtube.com/embed/${e}`,frameBorder:0,onLoad:()=>s(!0),allowFullScreen:!0,className:Y},i))]}))}))}))},dailymotion:function(t){var{providerId:e}=t,i=w(t,["providerId"]);const o=u(null),[n,s]=p(null),[r,a]=p(!1),{isIntersecting:h}=x(o,{freezeOnceVisible:!0,rootMargin:"50%"});return c((()=>{fetch((t=>`https://api.dailymotion.com/video/${t}?fields=thumbnail_url`)(e)).then((t=>t.json())).then((t=>s(t.thumbnail_url))).catch((()=>s(null)))}),[e]),l("div",Object.assign({className:O,ref:o},{children:l("div",Object.assign({className:N},{children:d("div",Object.assign({className:R},{children:[l("img",{src:n||"",alt:"daylimotion_video_preview",width:"100%",height:"100%",className:j,style:{opacity:h&&r?0:1,zIndex:h&&r?-1:0}}),h&&l("iframe",Object.assign({title:"Dailymotion Video Player",frameBorder:0,onLoad:()=>a(!0),src:`https://www.dailymotion.com/embed/video/${e}`,allowFullScreen:!0,className:S},i))]}))}))}))},twitter:function({providerId:t}){const e=u(null),{isIntersecting:i}=x(e,{freezeOnceVisible:!0,rootMargin:"50%"});return c((()=>{var o;if(!i)return;const n=document.createElement("script");n.src="https://platform.twitter.com/widgets.js",null===(o=e.current)||void 0===o||o.appendChild(n),n.onload=()=>{window.twttr&&window.twttr.widgets.createTweet(t,document.getElementById(t),{align:"center",conversation:"none",dnt:!0,theme:"dark",height:500})}}),[t,i]),l("div",Object.assign({className:I,ref:e},{children:l("div",Object.assign({className:_},{children:l("div",Object.assign({className:A},{children:l("div",{id:t})}))}))}))},figma:function(t){var{providerId:e,url:i}=t;w(t,["providerId","url"]);const o=u(null),{isIntersecting:n}=x(o,{freezeOnceVisible:!0,rootMargin:"50%"});return l("div",Object.assign({className:P,ref:o},{children:l("div",Object.assign({className:k},{children:l("div",Object.assign({className:B},{children:n&&l("iframe",{src:`https://www.figma.com/embed?embed_host=share&url=${encodeURIComponent(i)}`,frameBorder:0,allowFullScreen:!0,className:M,height:"450px"})}))}))}))}};var $,K,tt=($=function(t,e){return $=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},$(t,e)},function(t,e){function i(){this.constructor=t}$(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),et=function(){return et=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},et.apply(this,arguments)},it={width:"100%",height:"10px",top:"0px",left:"0px",cursor:"row-resize"},ot={width:"10px",height:"100%",top:"0px",left:"0px",cursor:"col-resize"},nt={width:"20px",height:"20px",position:"absolute"},st={top:et(et({},it),{top:"-5px"}),right:et(et({},ot),{left:void 0,right:"-5px"}),bottom:et(et({},it),{top:void 0,bottom:"-5px"}),left:et(et({},ot),{left:"-5px"}),topRight:et(et({},nt),{right:"-10px",top:"-10px",cursor:"ne-resize"}),bottomRight:et(et({},nt),{right:"-10px",bottom:"-10px",cursor:"se-resize"}),bottomLeft:et(et({},nt),{left:"-10px",bottom:"-10px",cursor:"sw-resize"}),topLeft:et(et({},nt),{left:"-10px",top:"-10px",cursor:"nw-resize"})},rt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.onMouseDown=function(t){e.props.onResizeStart(t,e.props.direction)},e.onTouchStart=function(t){e.props.onResizeStart(t,e.props.direction)},e}return tt(e,t),e.prototype.render=function(){return h.createElement("div",{className:this.props.className||"",style:et(et({position:"absolute",userSelect:"none"},st[this.props.direction]),this.props.replaceStyles||{}),onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart},this.props.children)},e}(h.PureComponent),at=function(){var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)};return function(e,i){function o(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}(),lt=function(){return lt=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},lt.apply(this,arguments)},dt={width:"auto",height:"auto"},ht=function(t,e,i){return Math.max(Math.min(t,i),e)},pt=function(t,e){return Math.round(t/e)*e},ct=function(t,e){return new RegExp(t,"i").test(e)},ut=function(t){return Boolean(t.touches&&t.touches.length)},gt=function(t,e,i){void 0===i&&(i=0);var o=e.reduce((function(i,o,n){return Math.abs(o-t)<Math.abs(e[i]-t)?n:i}),0),n=Math.abs(e[o]-t);return 0===i||n<i?e[o]:t},ft=function(t){return"auto"===(t=t.toString())||t.endsWith("px")||t.endsWith("%")||t.endsWith("vh")||t.endsWith("vw")||t.endsWith("vmax")||t.endsWith("vmin")?t:t+"px"},mt=function(t,e,i,o){if(t&&"string"==typeof t){if(t.endsWith("px"))return Number(t.replace("px",""));if(t.endsWith("%"))return e*(Number(t.replace("%",""))/100);if(t.endsWith("vw"))return i*(Number(t.replace("vw",""))/100);if(t.endsWith("vh"))return o*(Number(t.replace("vh",""))/100)}return t},vt=["as","style","className","grid","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],bt="__resizable_base__",wt=function(t){function e(e){var i=t.call(this,e)||this;return i.ratio=1,i.resizable=null,i.parentLeft=0,i.parentTop=0,i.resizableLeft=0,i.resizableRight=0,i.resizableTop=0,i.resizableBottom=0,i.targetLeft=0,i.targetTop=0,i.appendBase=function(){if(!i.resizable||!i.window)return null;var t=i.parentNode;if(!t)return null;var e=i.window.document.createElement("div");return e.style.width="100%",e.style.height="100%",e.style.position="absolute",e.style.transform="scale(0, 0)",e.style.left="0",e.style.flex="0 0 100%",e.classList?e.classList.add(bt):e.className+=bt,t.appendChild(e),e},i.removeBase=function(t){var e=i.parentNode;e&&e.removeChild(t)},i.ref=function(t){t&&(i.resizable=t)},i.state={isResizing:!1,width:void 0===(i.propsSize&&i.propsSize.width)?"auto":i.propsSize&&i.propsSize.width,height:void 0===(i.propsSize&&i.propsSize.height)?"auto":i.propsSize&&i.propsSize.height,direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},i.onResizeStart=i.onResizeStart.bind(i),i.onMouseMove=i.onMouseMove.bind(i),i.onMouseUp=i.onMouseUp.bind(i),i}return at(e,t),Object.defineProperty(e.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"window",{get:function(){return this.resizable&&this.resizable.ownerDocument?this.resizable.ownerDocument.defaultView:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||dt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){var t=0,e=0;if(this.resizable&&this.window){var i=this.resizable.offsetWidth,o=this.resizable.offsetHeight,n=this.resizable.style.position;"relative"!==n&&(this.resizable.style.position="relative"),t="auto"!==this.resizable.style.width?this.resizable.offsetWidth:i,e="auto"!==this.resizable.style.height?this.resizable.offsetHeight:o,this.resizable.style.position=n}return{width:t,height:e}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sizeStyle",{get:function(){var t=this,e=this.props.size,i=function(e){if(void 0===t.state[e]||"auto"===t.state[e])return"auto";if(t.propsSize&&t.propsSize[e]&&t.propsSize[e].toString().endsWith("%")){if(t.state[e].toString().endsWith("%"))return t.state[e].toString();var i=t.getParentSize();return Number(t.state[e].toString().replace("px",""))/i[e]*100+"%"}return ft(t.state[e])};return{width:e&&void 0!==e.width&&!this.state.isResizing?ft(e.width):i("width"),height:e&&void 0!==e.height&&!this.state.isResizing?ft(e.height):i("height")}},enumerable:!1,configurable:!0}),e.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var t=this.appendBase();if(!t)return{width:0,height:0};var e=!1,i=this.parentNode.style.flexWrap;"wrap"!==i&&(e=!0,this.parentNode.style.flexWrap="wrap"),t.style.position="relative",t.style.minWidth="100%",t.style.minHeight="100%";var o={width:t.offsetWidth,height:t.offsetHeight};return e&&(this.parentNode.style.flexWrap=i),this.removeBase(t),o},e.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},e.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},e.prototype.componentDidMount=function(){if(this.resizable&&this.window){var t=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:"auto"!==t.flexBasis?t.flexBasis:void 0})}},e.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},e.prototype.createSizeForCssProperty=function(t,e){var i=this.propsSize&&this.propsSize[e];return"auto"!==this.state[e]||this.state.original[e]!==t||void 0!==i&&"auto"!==i?t:"auto"},e.prototype.calculateNewMaxFromBoundary=function(t,e){var i,o,n=this.props.boundsByDirection,s=this.state.direction,r=n&&ct("left",s),a=n&&ct("top",s);if("parent"===this.props.bounds){var l=this.parentNode;l&&(i=r?this.resizableRight-this.parentLeft:l.offsetWidth+(this.parentLeft-this.resizableLeft),o=a?this.resizableBottom-this.parentTop:l.offsetHeight+(this.parentTop-this.resizableTop))}else"window"===this.props.bounds?this.window&&(i=r?this.resizableRight:this.window.innerWidth-this.resizableLeft,o=a?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(i=r?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),o=a?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return i&&Number.isFinite(i)&&(t=t&&t<i?t:i),o&&Number.isFinite(o)&&(e=e&&e<o?e:o),{maxWidth:t,maxHeight:e}},e.prototype.calculateNewSizeFromDirection=function(t,e){var i=this.props.scale||1,o=this.props.resizeRatio||1,n=this.state,s=n.direction,r=n.original,a=this.props,l=a.lockAspectRatio,d=a.lockAspectRatioExtraHeight,h=a.lockAspectRatioExtraWidth,p=r.width,c=r.height,u=d||0,g=h||0;return ct("right",s)&&(p=r.width+(t-r.x)*o/i,l&&(c=(p-g)/this.ratio+u)),ct("left",s)&&(p=r.width-(t-r.x)*o/i,l&&(c=(p-g)/this.ratio+u)),ct("bottom",s)&&(c=r.height+(e-r.y)*o/i,l&&(p=(c-u)*this.ratio+g)),ct("top",s)&&(c=r.height-(e-r.y)*o/i,l&&(p=(c-u)*this.ratio+g)),{newWidth:p,newHeight:c}},e.prototype.calculateNewSizeFromAspectRatio=function(t,e,i,o){var n=this.props,s=n.lockAspectRatio,r=n.lockAspectRatioExtraHeight,a=n.lockAspectRatioExtraWidth,l=void 0===o.width?10:o.width,d=void 0===i.width||i.width<0?t:i.width,h=void 0===o.height?10:o.height,p=void 0===i.height||i.height<0?e:i.height,c=r||0,u=a||0;if(s){var g=(h-c)*this.ratio+u,f=(p-c)*this.ratio+u,m=(l-u)/this.ratio+c,v=(d-u)/this.ratio+c,b=Math.max(l,g),w=Math.min(d,f),y=Math.max(h,m),x=Math.min(p,v);t=ht(t,b,w),e=ht(e,y,x)}else t=ht(t,l,d),e=ht(e,h,p);return{newWidth:t,newHeight:e}},e.prototype.setBoundingClientRect=function(){if("parent"===this.props.bounds){var t=this.parentNode;if(t){var e=t.getBoundingClientRect();this.parentLeft=e.left,this.parentTop=e.top}}if(this.props.bounds&&"string"!=typeof this.props.bounds){var i=this.props.bounds.getBoundingClientRect();this.targetLeft=i.left,this.targetTop=i.top}if(this.resizable){var o=this.resizable.getBoundingClientRect(),n=o.left,s=o.top,r=o.right,a=o.bottom;this.resizableLeft=n,this.resizableRight=r,this.resizableTop=s,this.resizableBottom=a}},e.prototype.onResizeStart=function(t,e){if(this.resizable&&this.window){var i,o=0,n=0;if(t.nativeEvent&&function(t){return Boolean((t.clientX||0===t.clientX)&&(t.clientY||0===t.clientY))}(t.nativeEvent)?(o=t.nativeEvent.clientX,n=t.nativeEvent.clientY):t.nativeEvent&&ut(t.nativeEvent)&&(o=t.nativeEvent.touches[0].clientX,n=t.nativeEvent.touches[0].clientY),this.props.onResizeStart)if(this.resizable)if(!1===this.props.onResizeStart(t,e,this.resizable))return;this.props.size&&(void 0!==this.props.size.height&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),void 0!==this.props.size.width&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio="number"==typeof this.props.lockAspectRatio?this.props.lockAspectRatio:this.size.width/this.size.height;var s=this.window.getComputedStyle(this.resizable);if("auto"!==s.flexBasis){var r=this.parentNode;if(r){var a=this.window.getComputedStyle(r).flexDirection;this.flexDir=a.startsWith("row")?"row":"column",i=s.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var l={original:{x:o,y:n,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:lt(lt({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(t.target).cursor||"auto"}),direction:e,flexBasis:i};this.setState(l)}},e.prototype.onMouseMove=function(t){var e=this;if(this.state.isResizing&&this.resizable&&this.window){if(this.window.TouchEvent&&ut(t))try{t.preventDefault(),t.stopPropagation()}catch(t){}var i=this.props,o=i.maxWidth,n=i.maxHeight,s=i.minWidth,r=i.minHeight,a=ut(t)?t.touches[0].clientX:t.clientX,l=ut(t)?t.touches[0].clientY:t.clientY,d=this.state,h=d.direction,p=d.original,c=d.width,u=d.height,g=this.getParentSize(),m=function(t,e,i,o,n,s,r){return o=mt(o,t.width,e,i),n=mt(n,t.height,e,i),s=mt(s,t.width,e,i),r=mt(r,t.height,e,i),{maxWidth:void 0===o?void 0:Number(o),maxHeight:void 0===n?void 0:Number(n),minWidth:void 0===s?void 0:Number(s),minHeight:void 0===r?void 0:Number(r)}}(g,this.window.innerWidth,this.window.innerHeight,o,n,s,r);o=m.maxWidth,n=m.maxHeight,s=m.minWidth,r=m.minHeight;var v=this.calculateNewSizeFromDirection(a,l),b=v.newHeight,w=v.newWidth,y=this.calculateNewMaxFromBoundary(o,n);this.props.snap&&this.props.snap.x&&(w=gt(w,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(b=gt(b,this.props.snap.y,this.props.snapGap));var x=this.calculateNewSizeFromAspectRatio(w,b,{width:y.maxWidth,height:y.maxHeight},{width:s,height:r});if(w=x.newWidth,b=x.newHeight,this.props.grid){var z=pt(w,this.props.grid[0]),O=pt(b,this.props.grid[1]),S=this.props.snapGap||0;w=0===S||Math.abs(z-w)<=S?z:w,b=0===S||Math.abs(O-b)<=S?O:b}var N={width:w-p.width,height:b-p.height};if(c&&"string"==typeof c)if(c.endsWith("%"))w=w/g.width*100+"%";else if(c.endsWith("vw")){w=w/this.window.innerWidth*100+"vw"}else if(c.endsWith("vh")){w=w/this.window.innerHeight*100+"vh"}if(u&&"string"==typeof u)if(u.endsWith("%"))b=b/g.height*100+"%";else if(u.endsWith("vw")){b=b/this.window.innerWidth*100+"vw"}else if(u.endsWith("vh")){b=b/this.window.innerHeight*100+"vh"}var j={width:this.createSizeForCssProperty(w,"width"),height:this.createSizeForCssProperty(b,"height")};"row"===this.flexDir?j.flexBasis=j.width:"column"===this.flexDir&&(j.flexBasis=j.height),f((function(){e.setState(j)})),this.props.onResize&&this.props.onResize(t,h,this.resizable,N)}},e.prototype.onMouseUp=function(t){var e=this.state,i=e.isResizing,o=e.direction,n=e.original;if(i&&this.resizable){var s={width:this.size.width-n.width,height:this.size.height-n.height};this.props.onResizeStop&&this.props.onResizeStop(t,o,this.resizable,s),this.props.size&&this.setState(this.props.size),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:lt(lt({},this.state.backgroundStyle),{cursor:"auto"})})}},e.prototype.updateSize=function(t){this.setState({width:t.width,height:t.height})},e.prototype.renderResizer=function(){var t=this,e=this.props,i=e.enable,o=e.handleStyles,n=e.handleClasses,s=e.handleWrapperStyle,r=e.handleWrapperClass,a=e.handleComponent;if(!i)return null;var l=Object.keys(i).map((function(e){return!1!==i[e]?h.createElement(rt,{key:e,direction:e,onResizeStart:t.onResizeStart,replaceStyles:o&&o[e],className:n&&n[e]},a&&a[e]?a[e]:null):null}));return h.createElement("div",{className:r,style:s},l)},e.prototype.render=function(){var t=this,e=Object.keys(this.props).reduce((function(e,i){return-1!==vt.indexOf(i)||(e[i]=t.props[i]),e}),{}),i=lt(lt(lt({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(i.flexBasis=this.state.flexBasis);var o=this.props.as||"div";return h.createElement(o,lt({ref:this.ref,style:i,className:this.props.className},e),this.state.isResizing&&h.createElement("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer())},e.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},e}(h.PureComponent);function yt(){return yt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o])}return t},yt.apply(this,arguments)}var xt=function(t){return h.createElement("svg",yt({fill:"currentColor","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"uploadImage"},t),K||(K=h.createElement("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"})))},zt="_5ZnGUwAU",Ot="wlwFaZpx",St="Obm15-qh",Nt="gJ5-oVLV",jt="_6jUel99o",Rt="HZgHUcV-",Et="GF1PbH1g gU1gU-Wq",Wt="i7UwLauz",Ht="cJSOiHYH";z('._5ZnGUwAU{position:fixed}.wlwFaZpx{background:#fff;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:100%;max-height:420px;max-width:calc(100vw - 24px);min-width:540px}.Obm15-qh{box-shadow:inset 0 -1px 0 rgba(55,53,47,.09);display:flex;height:40px;padding:0 8px;width:100%;z-index:1}.Obm15-qh,.gJ5-oVLV{font-size:14px;position:relative}.gJ5-oVLV{align-items:center;background-color:inherit;border:none;border-radius:4px;color:#37352f;cursor:pointer;display:inline-flex;flex-shrink:0;height:100%;line-height:1.2;min-width:0;padding:6px 8px;transition:height 20ms ease-in 0s;user-select:none;white-space:nowrap}._6jUel99o:after{background-color:#37352f;bottom:0;content:"";height:2px;left:0;position:absolute;width:100%}.HZgHUcV-{display:flex;justify-content:center;margin-left:12px;margin-right:12px;margin-top:4px;padding-bottom:6px;padding-top:6px}.gU1gU-Wq{border:1px solid rgba(55,53,47,.16);border-radius:4px;cursor:pointer;height:32px;padding-left:12px;padding-right:12px;transition:background 20ms ease-in 0s;user-select:none;white-space:nowrap;width:100%}.GF1PbH1g{border:none!important;cursor:pointer!important;height:auto!important;padding-left:0!important;padding-right:0!important}.i2lz5EKx{align-items:center;cursor:pointer;display:inline-flex;font-size:14px;font-weight:500;height:100%;justify-content:center;line-height:1.2;width:100%}._3cPFLttW{left:0;position:absolute;top:0;visibility:hidden}.i7UwLauz{background:hsla(45,13%,94%,.6);box-shadow:inset 0 0 0 1px hsla(0,0%,6%,.1);cursor:text;height:32px;line-height:20px;padding:3px 6px;position:relative}.cJSOiHYH,.i7UwLauz{align-items:center;border:none;border-radius:4px;display:flex;font-size:14px;width:100%}.cJSOiHYH{fill:#fff;background:#2383e2;box-shadow:inset 0 0 0 1px hsla(0,0%,6%,.1),0 1px 2px hsla(0,0%,6%,.1);color:#fff;cursor:pointer;flex-shrink:0;font-weight:500;height:28px;justify-content:center;line-height:1.2;margin:12px auto 6px;max-width:300px;padding-left:12px;padding-right:12px;transition:background 20ms ease-in 0s;user-select:none;white-space:nowrap}');const Ct=({onEmbed:t})=>{const[e,i]=p("");return d("div",Object.assign({className:Et},{children:[l("input",{type:"text",placeholder:"Paste embed link",value:e,className:Wt,onChange:t=>i(t.target.value)}),l("button",Object.assign({type:"button",className:Ht,onClick:()=>t(e)},{children:"Embed"}))]}))},Lt=({style:t,onEmbed:o,onClose:n})=>d(e.Overlay,Object.assign({onClose:n},{children:[l("div",Object.assign({className:zt,style:t},{children:d("div",Object.assign({className:Ot},{children:[l("div",Object.assign({className:St},{children:l("button",Object.assign({type:"button",className:i(Nt,{[jt]:!0})},{children:"Embed link"}))})),l("div",Object.assign({className:Rt},{children:l(Ct,{onEmbed:o})}))]}))})),l("div",{})]}));var Pt=!1;if("undefined"!=typeof window){var Mt={get passive(){Pt=!0}};window.addEventListener("testPassive",null,Mt),window.removeEventListener("testPassive",null,Mt)}var kt="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),Bt=[],It=!1,_t=-1,At=void 0,Tt=void 0,Vt=void 0,Ft=function(t){return Bt.some((function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(t))}))},Ut=function(t){var e=t||window.event;return!!Ft(e.target)||(e.touches.length>1||(e.preventDefault&&e.preventDefault(),!1))},Dt=function(t,e){if(t){if(!Bt.some((function(e){return e.targetElement===t}))){var i={targetElement:t,options:e||{}};Bt=[].concat(function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}(Bt),[i]),kt?window.requestAnimationFrame((function(){if(void 0===Tt){Tt={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var t=window,e=t.scrollY,i=t.scrollX,o=t.innerHeight;document.body.style.position="fixed",document.body.style.top=-e,document.body.style.left=-i,setTimeout((function(){return window.requestAnimationFrame((function(){var t=o-window.innerHeight;t&&e>=o&&(document.body.style.top=-(e+t))}))}),300)}})):function(t){if(void 0===Vt){var e=!!t&&!0===t.reserveScrollBarGap,i=window.innerWidth-document.documentElement.clientWidth;if(e&&i>0){var o=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);Vt=document.body.style.paddingRight,document.body.style.paddingRight=o+i+"px"}}void 0===At&&(At=document.body.style.overflow,document.body.style.overflow="hidden")}(e),kt&&(t.ontouchstart=function(t){1===t.targetTouches.length&&(_t=t.targetTouches[0].clientY)},t.ontouchmove=function(e){1===e.targetTouches.length&&function(t,e){var i=t.targetTouches[0].clientY-_t;!Ft(t.target)&&(e&&0===e.scrollTop&&i>0||function(t){return!!t&&t.scrollHeight-t.scrollTop<=t.clientHeight}(e)&&i<0?Ut(t):t.stopPropagation())}(e,t)},It||(document.addEventListener("touchmove",Ut,Pt?{passive:!1}:void 0),It=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},Gt=function(t){t?(Bt=Bt.filter((function(e){return e.targetElement!==t})),kt&&(t.ontouchstart=null,t.ontouchmove=null,It&&0===Bt.length&&(document.removeEventListener("touchmove",Ut,Pt?{passive:!1}:void 0),It=!1)),kt?function(){if(void 0!==Tt){var t=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=Tt.position,document.body.style.top=Tt.top,document.body.style.left=Tt.left,window.scrollTo(e,t),Tt=void 0}}():(void 0!==Vt&&(document.body.style.paddingRight=Vt,Vt=void 0),void 0!==At&&(document.body.style.overflow=At,At=void 0))):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")},Yt="PoOhS4FU",qt="PcGiiPpV",Jt="iQZH4Lf-";z(".PoOhS4FU{margin:20px 0 10px;user-select:none}.PcGiiPpV,.PoOhS4FU{position:relative;width:100%}.PcGiiPpV{align-items:center;background-color:#efefef;border:none;border-radius:3px;color:rgba(55,53,47,.65);cursor:pointer;display:flex;font-size:14px;overflow:hidden;padding:12px 36px 12px 12px;text-align:left;transition:background-color .1s ease-in}.PcGiiPpV:hover{background-color:#e3e3e3}.iQZH4Lf-{margin-right:8px;user-select:none}");const Zt=({element:t,attributes:e,maxSizes:i,children:o,editor:n})=>{const[s,h]=p(null),c=u(null),g=t=>{var e;if(t.stopPropagation(),null!==s)return Gt(document.body),void h(null);const i=null===(e=c.current)||void 0===e?void 0:e.getBoundingClientRect();if(i){const t=i.top+i.height+88+20>window.innerHeight,e=!t;console.log({showAtTop:t,showAtBottom:e}),Dt(document.body,{reserveScrollBarGap:!0}),h({left:i.left,top:t?i.top-88-5:i.top+i.height+5})}};return d("div",Object.assign({className:Yt},e,{contentEditable:!1},{children:[d("div",Object.assign({ref:c},{children:[d("button",Object.assign({className:qt,onClick:g},{children:[l(xt,{className:Jt,width:24,height:24}),l("span",{children:"Click to add embed"})]})),null!==s&&l(Lt,{onEmbed:e=>y(void 0,void 0,void 0,(function*(){if(0===e.length)return;const i=(o=e).includes("youtube.com")||o.includes("youtu.be")?"youtube":o.includes("vimeo.com")?"vimeo":o.includes("dailymotion.com")||o.includes("dai.ly")?"dailymotion":o.includes("twitter")?"twitter":o.includes("figma")?"figma":null;var o;let s=null;"youtube"===i?s=(t=>{const e=t.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/);return e&&11===e[2].length?e[2]:null})(e):"vimeo"===i?s=(t=>new URL(t).pathname.split("/")[1])(e):"dailymotion"===i?s=(t=>{var e=t.match(/^.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/);return null!==e?void 0!==e[4]?e[4]:e[2]:null})(e):"twitter"===i?s=function(t){const e=t.match(/\/status\/(\d+)/);return e?e[1]:null}(e):"figma"===i&&(s=function(t){const e=new URL(t).searchParams,i=e.get("node-id");return e.get("node-id")?i:"unknown"}(e)),console.log({provider:i,providerId:s,element:t});try{console.log("path",m.findPath(n,t)),Gt(document.body),h(null);const o={data:Object.assign(Object.assign({},t.data),{url:e,size:{width:t.data.size.width,height:t.data.size.height},provider:i,providerId:s})};r.setNodes(n,o,{at:m.findPath(n,t),match:t=>a.isElement(t)&&"embed"===t.type})}catch(t){console.log("provider adding error",t),Gt(document.body),h(null)}})),onClose:g,style:s})]})),o]}))};var Qt="s8SlWwrL",Xt="_5qhGnBQW",$t="_6GzVi0JR",Kt="HLz36qUX OLRmQVp3",te="Tv1Fs118 OLRmQVp3",ee="_33V0MBSa",ie="VdsHNo29",oe="WARAR91D",ne="_92ciCRYx";z(".s8SlWwrL{cursor:pointer;display:block;position:relative}.s8SlWwrL:hover .OLRmQVp3,.s8SlWwrL:hover ._5qhGnBQW{opacity:1}._0z3X-ysz{pointer-events:none}._9GorNz7R{margin:20px 0 30px}._6GzVi0JR{margin:0 auto}.OLRmQVp3{align-items:center;cursor:col-resize;display:flex;height:100%;justify-content:center;opacity:0;pointer-events:none;position:absolute;transition:opacity .15s ease-in 0s;width:15px;z-index:1}.HLz36qUX{left:0;top:0}.Tv1Fs118{right:0;top:0}._33V0MBSa{background:hsla(0,0%,6%,.6);border:1px solid hsla(0,0%,100%,.9);border-radius:20px;box-shadow:0 0 0 .5px #fff;height:48px;max-height:50%;opacity:1;transition:opacity .3s ease-in 0s;width:6px}.VdsHNo29{opacity:0}.WARAR91D{background:rgba(35,131,226,.14);border-radius:3px;inset:0;opacity:1;pointer-events:none;position:absolute;transition:opacity .15s ease-in 0s;z-index:81}._8VNstZwX{left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}._5qhGnBQW{align-items:center;background-color:#eee;border:none;border-radius:2px;cursor:pointer;display:flex;height:22px;justify-content:space-between;opacity:0;padding:0 4px;position:absolute;right:10px;top:10px;transition:opacity .15s ease-in 0s;width:22px;z-index:1}._92ciCRYx{background-color:gray;border-radius:50%;min-height:3px;min-width:3px}");function se(t){var o,n,s,h,u;const{element:f,editor:w,plugin:y}=t,x=v(),z=b(),[O,S]=p(null),[N,j]=p({width:(null===(n=null===(o=f.data)||void 0===o?void 0:o.size)||void 0===n?void 0:n.width)||750,height:(null===(h=null===(s=f.data)||void 0===s?void 0:s.size)||void 0===h?void 0:h.height)||440}),R=t=>j(Object.assign(Object.assign({},N),t));c((()=>{var t,e,i,o;f.data&&R({width:(null===(e=null===(t=f.data)||void 0===t?void 0:t.size)||void 0===e?void 0:e.width)||750,height:(null===(o=null===(i=f.data)||void 0===i?void 0:i.size)||void 0===o?void 0:o.height)||440})}),[null===(u=f.data)||void 0===u?void 0:u.size]);const E=g((()=>{var t,e;return{minWidth:300,size:{width:N.width,height:N.height},maxWidth:(null===(t=y.options)||void 0===t?void 0:t.maxWidth)||800,maxHeight:(null===(e=y.options)||void 0===e?void 0:e.maxHeight)||720,lockAspectRatio:!0,resizeRatio:2,enable:{left:!z,right:!z},handleStyles:{left:{left:0},right:{right:0}},onResize:(t,e,i)=>{R({width:i.offsetWidth,height:i.offsetHeight})},onResizeStop:(t,e,i)=>{console.log("image editor editor.children",w.children),console.log("ReactEditor.findPath(editor, element)",m.findPath(w,f)),console.log("element",f),r.setNodes(w,{data:Object.assign(Object.assign({},f.data),{size:{width:i.offsetWidth,height:i.offsetHeight}})},{at:m.findPath(w,f),match:t=>a.isElement(t)&&"embed"===t.type})},handleComponent:{left:l("div",Object.assign({contentEditable:!1,className:Kt},{children:l("div",{className:ee})})),right:l("div",Object.assign({contentEditable:!1,className:te},{children:l("div",{className:ee})}))}}}),[N.width,N.height,w]),W=()=>{Gt(document.body),S(null)},H=t=>{var e;if(null==t||t.stopPropagation(),null!==O)return W();const i=null===(e=null==t?void 0:t.currentTarget)||void 0===e?void 0:e.getBoundingClientRect();if(i){const t=i.top+i.height+164+20>window.innerHeight;Dt(document.body,{reserveScrollBarGap:!0}),S({left:i.right-i.width+265>window.innerWidth?window.innerWidth-265-i.width:i.right-i.width,top:t?i.top-82-i.height:i.top+i.height+5})}};if(!f.data.url&&!f.data["data-src"]){const{maxWidth:o=750,maxHeight:n=800}=y.options||{};return d("div",Object.assign({className:Qt,contentEditable:!1,draggable:!1},{children:[l("div",{className:i(ie,{[oe]:x})}),l(Zt,Object.assign({attributes:t.attributes,element:f,editor:w,maxSizes:{maxWidth:o,maxHeight:n}},{children:!z&&d("div",{children:[d("button",Object.assign({type:"button",className:Xt,onClick:H},{children:[l("span",{className:ne}),l("span",{className:ne}),l("span",{className:ne})]})),null!==O&&l(e.ElementOptions,{onClose:W,style:O,element:f,onCopy:W,onDelete:W,onDuplicate:W},f.id)]})})),t.children]}),f.id)}return l("div",Object.assign({contentEditable:!1,draggable:!1,className:Qt},{children:d(wt,Object.assign({},E,{className:$t},{children:[y.renderer.render(Object.assign(Object.assign({},t),{size:N,isEdit:!0})),l("div",{className:i(ie,{[oe]:x})}),!z&&d("div",{children:[d("button",Object.assign({type:"button",className:Xt,onClick:H},{children:[l("span",{className:ne}),l("span",{className:ne}),l("span",{className:ne})]})),null!==O&&l(e.ElementOptions,{onClose:W,style:O,element:f,onCopy:W,onDelete:W,onDuplicate:W},f.id)]})]}))}),f.id)}const re=o({type:"embed",shortcut:"embed",renderer:{editor:(t,e)=>i=>l(se,Object.assign({editor:t,plugin:e},i)),render:({attributes:e,element:i,children:o,HTMLAttributes:n,isEdit:s=!1})=>{if("string"==typeof i.data.provider&&i.data.providerId&&X[i.data.provider]){const r=X[i.data.provider];return d("div",Object.assign({},e,{contentEditable:!1,draggable:!1},n,{style:s?void 0:i.data.size,className:t({element:i,HTMLAttributes:n,className:Q})},{children:[l(r,Object.assign({},i.data,{providerId:i.data.providerId})),o]}))}return i.data.url?d("div",Object.assign({},e,{contentEditable:!1,draggable:!1},n,{className:t({element:i,HTMLAttributes:n,className:Q}),style:s?void 0:i.data.size},{children:[l(L,Object.assign({},i.data,{providerId:i.data.providerId})),o]})):l("div",{})}},extendEditor(t){const{isVoid:e}=t;return t.isVoid=t=>t.type===re.getPlugin.type||e(t),t},events:{onKeyDown:(t,{defaultNode:e,hotkeys:i})=>o=>{var s;if("embed"===n(t,null===(s=t.selection)||void 0===s?void 0:s.anchor.path,"highest").type&&t.selection)return i.isEnter(o)?(o.preventDefault(),void r.insertNodes(t,e,{mode:"highest"})):void 0}},defineElement:()=>({id:s(),type:"embed",nodeType:"void",data:{url:null,size:{width:"auto",height:"auto"},providerId:null},children:[{text:""}]}),createElement:(t,e)=>{var i;const o=Object.assign(Object.assign({},re.getPlugin.defineElement()),e);r.setNodes(t,o,{at:null===(i=t.selection)||void 0===i?void 0:i.anchor})},exports:{markdown:{serialize:(t,e)=>`[embed-url](${t.data.url})\n`},html:{serialize:(t,e)=>{var i,o;return`<iframe src="https://player.vimeo.com/video/807053663?badge=0&amp;byline=0&amp;portrait=0&amp;title=0" frameborder="0" height="${null===(i=t.data.size)||void 0===i?void 0:i.height}" width="${null===(o=t.data.size)||void 0===o?void 0:o.width}" allowfullscreen="" url="https://vimeo.com/807053663" provider="${t.data.provider||""}" />`},deserialize:{nodeName:"IFRAME",parse:t=>({url:t.getAttribute("src"),size:{height:"string"==typeof t.getAttribute("height")?Number(t.getAttribute("height")):"auto",width:"string"==typeof t.getAttribute("width")?Number(t.getAttribute("width")):"auto"}})}}},options:{searchString:"Embed media",displayLabel:"Embed"}});export{re as default};
@@ -1,12 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { RenderYooptaElementProps, YooEditor, YooptaPluginType } from '@yoopta/editor';
3
- import { EmbedElement, EmbedPluginOptions } from '../types';
4
- type Props = {
5
- editor: YooEditor;
6
- plugin: YooptaPluginType<EmbedPluginOptions, EmbedElement>;
7
- element: RenderYooptaElementProps<EmbedElement>['element'];
8
- children: RenderYooptaElementProps<EmbedElement>['children'];
9
- attributes: RenderYooptaElementProps<EmbedElement>['attributes'];
10
- };
11
- declare const EmbedEditorFactory: (editor: Props['editor'], plugin: Props['plugin']) => (props: RenderYooptaElementProps<EmbedElement>) => JSX.Element;
2
+ import { EmbedElementData } from '../types';
3
+ declare const EmbedEditorFactory: (editor: YooEditor, plugin: YooptaPluginType<any, Modify<YooptaBaseElement<"embed">, {
4
+ data: EmbedElementData;
5
+ }>>) => (props: RenderYooptaElementProps<Modify<YooptaBaseElement<"embed">, {
6
+ data: EmbedElementData;
7
+ }>>) => JSX.Element;
12
8
  export { EmbedEditorFactory };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoopta/embed",
3
- "version": "1.9.178-rc",
3
+ "version": "2.0.0",
4
4
  "description": "> TODO: description",
5
5
  "author": "Darginec05 <devopsbanda@gmail.com>",
6
6
  "homepage": "https://github.com/Darginec05/Editor-Yoopta#readme",
@@ -33,4 +33,4 @@
33
33
  "bugs": {
34
34
  "url": "https://github.com/Darginec05/Editor-Yoopta/issues"
35
35
  }
36
- }
36
+ }