@yoopta/editor 1.9.17-rc → 1.9.19-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.
- package/dist/components/YooptaEditor/YooptaEditor.d.ts +2 -19
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/types.d.ts +18 -1
- package/package.json +1 -1
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
import { Key
|
|
2
|
-
import { YooptaBaseElement, YooptaEditorValue } from '../../types';
|
|
1
|
+
import { Key } from 'react';
|
|
2
|
+
import { YooptaBaseElement, YooptaEditorValue, YooptaTools, YooptaNodeElementSettings } from '../../types';
|
|
3
3
|
import { YooptaMark } from '../../utils/marks';
|
|
4
4
|
import { YooptaPlugin } from '../../utils/plugins';
|
|
5
5
|
import { OFFLINE_STORAGE } from '../../utils/storage';
|
|
6
|
-
export type YooptaNodeElementSettings = {
|
|
7
|
-
options?: {
|
|
8
|
-
handlers?: {
|
|
9
|
-
onCopy?: () => void;
|
|
10
|
-
onDelete?: () => void;
|
|
11
|
-
onDuplicate?: () => void;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
drag?: boolean;
|
|
15
|
-
plus?: boolean;
|
|
16
|
-
};
|
|
17
|
-
export type YooptaTools = {
|
|
18
|
-
ActionMenu?: ReactNode;
|
|
19
|
-
Toolbar?: ReactNode;
|
|
20
|
-
ChatGPT?: ReactNode;
|
|
21
|
-
[x: string]: ReactNode;
|
|
22
|
-
};
|
|
23
6
|
export type YooptaEditorProps<V> = {
|
|
24
7
|
onChange: (_value: YooptaEditorValue<V>) => void;
|
|
25
8
|
value: YooptaEditorValue<V>;
|
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export { isElementActive, getElementByPath } from './utils/nodes';
|
|
|
17
17
|
export { getElementClassname } from './utils/getElementClassname';
|
|
18
18
|
export type { YooptaPluginType, YooptaPluginEventHandlers, HandlersOptions, YooptaPluginBaseOptions, YooptaRenderHTMLAttributes, } from './utils/plugins';
|
|
19
19
|
export type { YooptaMarksConfig, YooptaMark } from './utils/marks';
|
|
20
|
-
export type { YooEditor, RenderYooptaElementProps, YooptaBaseElement, Modify, YooptaEditorValue, YooptaBaseToolProps } from './types';
|
|
20
|
+
export type { YooEditor, RenderYooptaElementProps, YooptaBaseElement, Modify, YooptaEditorValue, YooptaBaseToolProps, YooptaTools, YooptaNodeElementSettings, } from './types';
|
|
21
21
|
declare const UI_HELPERS: {
|
|
22
22
|
ElementOptions: ({ onClose, style, element, render, ...props }: {
|
|
23
23
|
style: import("react").CSSProperties | undefined;
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import*as
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import*as r from"react";import o,{useState as i,useEffect as a,useContext as s,useMemo as l,useRef as c,memo as d,useCallback as u}from"react";import{createPortal as f}from"react-dom";import{ReactEditor as p,useSlate as h,useSelected as g,Editable as v,withReact as y,Slate as m}from"slate-react";import{Editor as b,Path as w,Transforms as _,Element as O,Text as x,Operation as E,Range as j,Node as k,createEditor as N}from"slate";import S from"crypto";function D(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function P(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}"function"==typeof SuppressedError&&SuppressedError;var A="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},C=200,T="__lodash_hash_undefined__",L="[object Function]",M="[object GeneratorFunction]",B=/^\[object .+?Constructor\]$/,F="object"==typeof A&&A&&A.Object===Object&&A,z="object"==typeof self&&self&&self.Object===Object&&self,H=F||z||Function("return this")();function R(e,t){return!!(e?e.length:0)&&function(e,t,n){if(t!=t)return function(e,t,n,r){var o=e.length,i=n+(r?1:-1);for(;r?i--:++i<o;)if(t(e[i],i,e))return i;return-1}(e,V,n);var r=n-1,o=e.length;for(;++r<o;)if(e[r]===t)return r;return-1}(e,t,0)>-1}function I(e,t,n){for(var r=-1,o=e?e.length:0;++r<o;)if(n(t,e[r]))return!0;return!1}function V(e){return e!=e}function W(e,t){return e.has(t)}function U(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var Z,$=Array.prototype,q=Function.prototype,K=Object.prototype,G=H["__core-js_shared__"],J=(Z=/[^.]+$/.exec(G&&G.keys&&G.keys.IE_PROTO||""))?"Symbol(src)_1."+Z:"",X=q.toString,Q=K.hasOwnProperty,Y=K.toString,ee=RegExp("^"+X.call(Q).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),te=$.splice,ne=pe(H,"Map"),re=pe(H,"Set"),oe=pe(Object,"create");function ie(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ae(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function se(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function le(e){var t=-1,n=e?e.length:0;for(this.__data__=new se;++t<n;)this.add(e[t])}function ce(e,t){for(var n,r,o=e.length;o--;)if((n=e[o][0])===(r=t)||n!=n&&r!=r)return o;return-1}function de(e){if(!he(e)||(t=e,J&&J in t))return!1;var t,n=function(e){var t=he(e)?Y.call(e):"";return t==L||t==M}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?ee:B;return n.test(function(e){if(null!=e){try{return X.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}ie.prototype.clear=function(){this.__data__=oe?oe(null):{}},ie.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},ie.prototype.get=function(e){var t=this.__data__;if(oe){var n=t[e];return n===T?void 0:n}return Q.call(t,e)?t[e]:void 0},ie.prototype.has=function(e){var t=this.__data__;return oe?void 0!==t[e]:Q.call(t,e)},ie.prototype.set=function(e,t){return this.__data__[e]=oe&&void 0===t?T:t,this},ae.prototype.clear=function(){this.__data__=[]},ae.prototype.delete=function(e){var t=this.__data__,n=ce(t,e);return!(n<0)&&(n==t.length-1?t.pop():te.call(t,n,1),!0)},ae.prototype.get=function(e){var t=this.__data__,n=ce(t,e);return n<0?void 0:t[n][1]},ae.prototype.has=function(e){return ce(this.__data__,e)>-1},ae.prototype.set=function(e,t){var n=this.__data__,r=ce(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},se.prototype.clear=function(){this.__data__={hash:new ie,map:new(ne||ae),string:new ie}},se.prototype.delete=function(e){return fe(this,e).delete(e)},se.prototype.get=function(e){return fe(this,e).get(e)},se.prototype.has=function(e){return fe(this,e).has(e)},se.prototype.set=function(e,t){return fe(this,e).set(e,t),this},le.prototype.add=le.prototype.push=function(e){return this.__data__.set(e,T),this},le.prototype.has=function(e){return this.__data__.has(e)};var ue=re&&1/U(new re([,-0]))[1]==1/0?function(e){return new re(e)}:function(){};function fe(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function pe(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return de(n)?n:void 0}function he(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}var ge,ve=function(e,t){return e&&e.length?function(e,t,n){var r=-1,o=R,i=e.length,a=!0,s=[],l=s;if(n)a=!1,o=I;else if(i>=C){var c=t?null:ue(e);if(c)return U(c);a=!1,o=W,l=new le}else l=t?[]:s;e:for(;++r<i;){var d=e[r],u=t?t(d):d;if(d=n||0!==d?d:0,a&&u==u){for(var f=l.length;f--;)if(l[f]===u)continue e;t&&l.push(u),s.push(d)}else o(l,u,n)||(l!==s&&l.push(u),s.push(d))}return s}(e,void 0,t):[]};class ye{constructor(e){ge.set(this,void 0),function(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===r?o.call(e,n):o?o.value=n:t.set(e,n)}(this,ge,Object.freeze(Object.assign({},e)),"f")}extend(e){const{type:t=P(this,ge,"f").type,renderer:n=P(this,ge,"f").renderer,placeholder:r=P(this,ge,"f").placeholder,shortcut:o=P(this,ge,"f").shortcut,exports:i=P(this,ge,"f").exports,events:a=P(this,ge,"f").events,options:s}=e,l=Object.freeze(Object.assign(Object.assign({},P(this,ge,"f")),{type:t,renderer:n,placeholder:r,shortcut:o,exports:i,events:a,options:Object.assign(Object.assign({},P(this,ge,"f").options),s)}));return new ye(l)}get getPlugin(){return P(this,ge,"f")}}function me(e){return new ye(e)}function be(e){const t=e.map((e=>{const t=e.getPlugin,{childPlugin:n}=t,r=D(t,["childPlugin"]);return n?[r,Object.assign(Object.assign({},n.getPlugin),{hasParent:!0})]:r})).flat();return ve(t,((e,t)=>e.type===t.type))}ge=new WeakMap;var we,_e={};
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2018 Jed Watson.
|
|
4
4
|
Licensed under the MIT License (MIT), see
|
|
5
5
|
http://jedwatson.github.io/classnames
|
|
6
6
|
*/
|
|
7
|
-
be={get exports(){return we},set exports(e){we=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(" ")}be.exports?(t.default=t,be.exports=t):window.classNames=t}();var _e=we;function Oe(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 xe="QEROK9NJ",Ee="ZLDKsGEc",je="_0wBAdXIb",ke="P40m4iJS",Ne="_7iHqOybQ";Oe(".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 Se=({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]),u(e("div",Object.assign({className:xe},{children:[t("div",{className:Ee}),e("div",Object.assign({className:je},{children:[t("div",{className:ke,onClick:r}),t("div",Object.assign({className:Ne,onClick:e=>e.stopPropagation()},{children:n}))]}))]})),a)};var De;function Pe(){return Pe=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},Pe.apply(this,arguments)}var Ae,Ce=function(e){return n.createElement("svg",Pe({viewBox:"0 0 16 16",className:"trash_svg__trash",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),De||(De=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 Te(){return Te=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},Te.apply(this,arguments)}var Le,Me=function(e){return n.createElement("svg",Te({viewBox:"0 0 16 16",className:"duplicate_svg__duplicate",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Ae||(Ae=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 Be(){return Be=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},Be.apply(this,arguments)}var Fe,ze=function(e){return n.createElement("svg",Be({viewBox:"0 0 16 16",className:"turn_svg__loop",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Le||(Le=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 He(){return He=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},He.apply(this,arguments)}var Re=function(e){return n.createElement("svg",He({viewBox:"0 0 16 16",className:"copy_svg__link",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Fe||(Fe=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"})))},Ie={};!function(e,t){var n=200,r="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",a="[object Boolean]",s="[object Date]",l="[object Function]",c="[object GeneratorFunction]",d="[object Map]",u="[object Number]",f="[object Object]",p="[object Promise]",h="[object RegExp]",g="[object Set]",v="[object String]",y="[object Symbol]",m="[object WeakMap]",b="[object ArrayBuffer]",w="[object DataView]",_="[object Float32Array]",O="[object Float64Array]",x="[object Int8Array]",E="[object Int16Array]",j="[object Int32Array]",k="[object Uint8Array]",N="[object Uint8ClampedArray]",S="[object Uint16Array]",D="[object Uint32Array]",A=/\w*$/,C=/^\[object .+?Constructor\]$/,T=/^(?:0|[1-9]\d*)$/,L={};L[i]=L["[object Array]"]=L[b]=L[w]=L[a]=L[s]=L[_]=L[O]=L[x]=L[E]=L[j]=L[d]=L[u]=L[f]=L[h]=L[g]=L[v]=L[y]=L[k]=L[N]=L[S]=L[D]=!0,L["[object Error]"]=L[l]=L[m]=!1;var M="object"==typeof P&&P&&P.Object===Object&&P,B="object"==typeof self&&self&&self.Object===Object&&self,F=M||B||Function("return this")(),z=t&&!t.nodeType&&t,H=z&&e&&!e.nodeType&&e,R=H&&H.exports===z;function I(e,t){return e.set(t[0],t[1]),e}function V(e,t){return e.add(t),e}function W(e,t,n,r){var o=-1,i=e?e.length:0;for(r&&i&&(n=e[++o]);++o<i;)n=t(n,e[o],o,e);return n}function U(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function Z(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function $(e,t){return function(n){return e(t(n))}}function q(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var K=Array.prototype,G=Function.prototype,J=Object.prototype,X=F["__core-js_shared__"],Q=function(){var e=/[^.]+$/.exec(X&&X.keys&&X.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Y=G.toString,ee=J.hasOwnProperty,te=J.toString,ne=RegExp("^"+Y.call(ee).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),re=R?F.Buffer:void 0,oe=F.Symbol,ie=F.Uint8Array,ae=$(Object.getPrototypeOf,Object),se=Object.create,le=J.propertyIsEnumerable,ce=K.splice,de=Object.getOwnPropertySymbols,ue=re?re.isBuffer:void 0,fe=$(Object.keys,Object),pe=ze(F,"DataView"),he=ze(F,"Map"),ge=ze(F,"Promise"),ve=ze(F,"Set"),ye=ze(F,"WeakMap"),me=ze(Object,"create"),be=We(pe),we=We(he),_e=We(ge),Oe=We(ve),xe=We(ye),Ee=oe?oe.prototype:void 0,je=Ee?Ee.valueOf:void 0;function ke(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Ne(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Se(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function De(e){this.__data__=new Ne(e)}function Pe(e,t){var n=Ze(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&$e(e)}(e)&&ee.call(e,"callee")&&(!le.call(e,"callee")||te.call(e)==i)}(e)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],r=n.length,o=!!r;for(var a in e)!t&&!ee.call(e,a)||o&&("length"==a||Ie(a,r))||n.push(a);return n}function Ae(e,t,n){var r=e[t];ee.call(e,t)&&Ue(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function Ce(e,t){for(var n=e.length;n--;)if(Ue(e[n][0],t))return n;return-1}function Te(e,t,n,r,o,p,m){var P;if(r&&(P=p?r(e,o,p,m):r(e)),void 0!==P)return P;if(!Ge(e))return e;var C=Ze(e);if(C){if(P=function(e){var t=e.length,n=e.constructor(t);t&&"string"==typeof e[0]&&ee.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!t)return function(e,t){var n=-1,r=e.length;t||(t=Array(r));for(;++n<r;)t[n]=e[n];return t}(e,P)}else{var T=Re(e),M=T==l||T==c;if(qe(e))return function(e,t){if(t)return e.slice();var n=new e.constructor(e.length);return e.copy(n),n}(e,t);if(T==f||T==i||M&&!p){if(U(e))return p?e:{};if(P=function(e){return"function"!=typeof e.constructor||Ve(e)?{}:(t=ae(e),Ge(t)?se(t):{});var t}(M?{}:e),!t)return function(e,t){return Be(e,He(e),t)}(e,function(e,t){return e&&Be(t,Je(t),e)}(P,e))}else{if(!L[T])return p?e:{};P=function(e,t,n,r){var o=e.constructor;switch(t){case b:return Me(e);case a:case s:return new o(+e);case w:return function(e,t){var n=t?Me(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,r);case _:case O:case x:case E:case j:case k:case N:case S:case D:return function(e,t){var n=t?Me(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}(e,r);case d:return function(e,t,n){var r=t?n(Z(e),!0):Z(e);return W(r,I,new e.constructor)}(e,r,n);case u:case v:return new o(e);case h:return function(e){var t=new e.constructor(e.source,A.exec(e));return t.lastIndex=e.lastIndex,t}(e);case g:return function(e,t,n){var r=t?n(q(e),!0):q(e);return W(r,V,new e.constructor)}(e,r,n);case y:return i=e,je?Object(je.call(i)):{}}var i}(e,T,Te,t)}}m||(m=new De);var B=m.get(e);if(B)return B;if(m.set(e,P),!C)var F=n?function(e){return function(e,t,n){var r=t(e);return Ze(e)?r:function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}(r,n(e))}(e,Je,He)}(e):Je(e);return function(e,t){for(var n=-1,r=e?e.length:0;++n<r&&!1!==t(e[n],n,e););}(F||e,(function(o,i){F&&(o=e[i=o]),Ae(P,i,Te(o,t,n,r,i,e,m))})),P}function Le(e){return!(!Ge(e)||(t=e,Q&&Q in t))&&(Ke(e)||U(e)?ne:C).test(We(e));var t}function Me(e){var t=new e.constructor(e.byteLength);return new ie(t).set(new ie(e)),t}function Be(e,t,n,r){n||(n={});for(var o=-1,i=t.length;++o<i;){var a=t[o],s=r?r(n[a],e[a],a,n,e):void 0;Ae(n,a,void 0===s?e[a]:s)}return n}function Fe(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function ze(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Le(n)?n:void 0}ke.prototype.clear=function(){this.__data__=me?me(null):{}},ke.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},ke.prototype.get=function(e){var t=this.__data__;if(me){var n=t[e];return n===r?void 0:n}return ee.call(t,e)?t[e]:void 0},ke.prototype.has=function(e){var t=this.__data__;return me?void 0!==t[e]:ee.call(t,e)},ke.prototype.set=function(e,t){return this.__data__[e]=me&&void 0===t?r:t,this},Ne.prototype.clear=function(){this.__data__=[]},Ne.prototype.delete=function(e){var t=this.__data__,n=Ce(t,e);return!(n<0)&&(n==t.length-1?t.pop():ce.call(t,n,1),!0)},Ne.prototype.get=function(e){var t=this.__data__,n=Ce(t,e);return n<0?void 0:t[n][1]},Ne.prototype.has=function(e){return Ce(this.__data__,e)>-1},Ne.prototype.set=function(e,t){var n=this.__data__,r=Ce(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Se.prototype.clear=function(){this.__data__={hash:new ke,map:new(he||Ne),string:new ke}},Se.prototype.delete=function(e){return Fe(this,e).delete(e)},Se.prototype.get=function(e){return Fe(this,e).get(e)},Se.prototype.has=function(e){return Fe(this,e).has(e)},Se.prototype.set=function(e,t){return Fe(this,e).set(e,t),this},De.prototype.clear=function(){this.__data__=new Ne},De.prototype.delete=function(e){return this.__data__.delete(e)},De.prototype.get=function(e){return this.__data__.get(e)},De.prototype.has=function(e){return this.__data__.has(e)},De.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Ne){var o=r.__data__;if(!he||o.length<n-1)return o.push([e,t]),this;r=this.__data__=new Se(o)}return r.set(e,t),this};var He=de?$(de,Object):function(){return[]},Re=function(e){return te.call(e)};function Ie(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||T.test(e))&&e>-1&&e%1==0&&e<t}function Ve(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||J)}function We(e){if(null!=e){try{return Y.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ue(e,t){return e===t||e!=e&&t!=t}(pe&&Re(new pe(new ArrayBuffer(1)))!=w||he&&Re(new he)!=d||ge&&Re(ge.resolve())!=p||ve&&Re(new ve)!=g||ye&&Re(new ye)!=m)&&(Re=function(e){var t=te.call(e),n=t==f?e.constructor:void 0,r=n?We(n):void 0;if(r)switch(r){case be:return w;case we:return d;case _e:return p;case Oe:return g;case xe:return m}return t});var Ze=Array.isArray;function $e(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=o}(e.length)&&!Ke(e)}var qe=ue||function(){return!1};function Ke(e){var t=Ge(e)?te.call(e):"";return t==l||t==c}function Ge(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Je(e){return $e(e)?Pe(e):function(e){if(!Ve(e))return fe(e);var t=[];for(var n in Object(e))ee.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return Te(e,!0,!0)}}({get exports(){return Ie},set exports(e){Ie=e}},Ie);var Ve=Ie;function We(e){return"function"==typeof window.structuredClone?window.structuredClone(e):Ve(e)}const Ue={from:{path:null,element:null,parent:null},to:{path:null,element:null,parent:null}};let Ze,$e,qe=(e=21)=>{var t;t=e-=0,!Ze||Ze.length<t?(Ze=Buffer.allocUnsafe(128*t),N(Ze),$e=0):$e+t>Ze.length&&(N(Ze),$e=0),$e+=t;let n="";for(let t=$e-e;t<$e;t++)n+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&Ze[t]];return n};const Ke=()=>{var e;return"undefined"==typeof window?qe():"function"!=typeof(null===(e=window.crypto)||void 0===e?void 0:e.randomUUID)?function(){let e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}():qe()};var Ge=!1;if("undefined"!=typeof window){var Je={get passive(){Ge=!0}};window.addEventListener("testPassive",null,Je),window.removeEventListener("testPassive",null,Je)}var Xe="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),Qe=[],Ye=!1,et=-1,tt=void 0,nt=void 0,rt=void 0,ot=function(e){return Qe.some((function(t){return!(!t.options.allowTouchMove||!t.options.allowTouchMove(e))}))},it=function(e){var t=e||window.event;return!!ot(t.target)||(t.touches.length>1||(t.preventDefault&&t.preventDefault(),!1))},at=function(e,t){if(e){if(!Qe.some((function(t){return t.targetElement===e}))){var n={targetElement:e,options:t||{}};Qe=[].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(Qe),[n]),Xe?window.requestAnimationFrame((function(){if(void 0===nt){nt={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var e=window,t=e.scrollY,n=e.scrollX,r=e.innerHeight;document.body.style.position="fixed",document.body.style.top=-t,document.body.style.left=-n,setTimeout((function(){return window.requestAnimationFrame((function(){var e=r-window.innerHeight;e&&t>=r&&(document.body.style.top=-(t+e))}))}),300)}})):function(e){if(void 0===rt){var t=!!e&&!0===e.reserveScrollBarGap,n=window.innerWidth-document.documentElement.clientWidth;if(t&&n>0){var r=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);rt=document.body.style.paddingRight,document.body.style.paddingRight=r+n+"px"}}void 0===tt&&(tt=document.body.style.overflow,document.body.style.overflow="hidden")}(t),Xe&&(e.ontouchstart=function(e){1===e.targetTouches.length&&(et=e.targetTouches[0].clientY)},e.ontouchmove=function(t){1===t.targetTouches.length&&function(e,t){var n=e.targetTouches[0].clientY-et;!ot(e.target)&&(t&&0===t.scrollTop&&n>0||function(e){return!!e&&e.scrollHeight-e.scrollTop<=e.clientHeight}(t)&&n<0?it(e):e.stopPropagation())}(t,e)},Ye||(document.addEventListener("touchmove",it,Ge?{passive:!1}:void 0),Ye=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},st=function(e){e?(Qe=Qe.filter((function(t){return t.targetElement!==e})),Xe&&(e.ontouchstart=null,e.ontouchmove=null,Ye&&0===Qe.length&&(document.removeEventListener("touchmove",it,Ge?{passive:!1}:void 0),Ye=!1)),Xe?function(){if(void 0!==nt){var e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);document.body.style.position=nt.position,document.body.style.top=nt.top,document.body.style.left=nt.left,window.scrollTo(t,e),nt=void 0}}():(void 0!==rt&&(document.body.style.paddingRight=rt,rt=void 0),void 0!==tt&&(document.body.style.overflow=tt,tt=void 0))):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")},lt=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],r=0;r<e.rangeCount;r++)n.push(e.getRangeAt(r));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEach((function(t){e.addRange(t)})),t&&t.focus()}},ct={"text/plain":"Text","text/html":"Url",default:"Text"},dt="Copy to clipboard: #{key}, Enter";var ut=function(e,t){var n,r,o,i,a,s,l=!1;t||(t={}),n=t.debug||!1;try{if(o=lt(),i=document.createRange(),a=document.getSelection(),(s=document.createElement("span")).textContent=e,s.ariaHidden="true",s.style.all="unset",s.style.position="fixed",s.style.top=0,s.style.clip="rect(0, 0, 0, 0)",s.style.whiteSpace="pre",s.style.webkitUserSelect="text",s.style.MozUserSelect="text",s.style.msUserSelect="text",s.style.userSelect="text",s.addEventListener("copy",(function(r){if(r.stopPropagation(),t.format)if(r.preventDefault(),void 0===r.clipboardData){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var o=ct[t.format]||ct.default;window.clipboardData.setData(o,e)}else r.clipboardData.clearData(),r.clipboardData.setData(t.format,e);t.onCopy&&(r.preventDefault(),t.onCopy(r.clipboardData))})),document.body.appendChild(s),i.selectNodeContents(s),a.addRange(i),!document.execCommand("copy"))throw new Error("copy command was unsuccessful");l=!0}catch(o){n&&console.error("unable to copy using execCommand: ",o),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),l=!0}catch(o){n&&console.error("unable to copy using clipboardData: ",o),n&&console.error("falling back to prompt"),r=function(e){var t=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return e.replace(/#{\s*key\s*}/g,t)}("message"in t?t.message:dt),window.prompt(r,e)}}finally{a&&("function"==typeof a.removeRange?a.removeRange(i):a.removeAllRanges()),s&&document.body.removeChild(s),o()}return l};const ft=e=>({id:e,type:"paragraph",nodeType:"block",children:[{text:""}]});function pt(e,t,n=!1){n&&Object.keys(m.marks(e)||{}).forEach((t=>{m.removeMark(e,t)})),!function(e,t){const n=m.marks(e);return!!(null==n?void 0:n[t])}(e,t)?m.addMark(e,t,!0):m.removeMark(e,t)}const ht={hoveredElement:null,isElementOptionsOpen:!1,nodeSettingsPos:null,dndState:Ue,disableWhileDrag:!1,DRAG_MAP:new Map,selectedNodeElement:null},gt=r.createContext([ht,{openNodeSettings:(e,t)=>{},closeNodeSettings:()=>{},hoverIn:(e,t)=>{},triggerPlusButton:e=>{},deleteNode:()=>{},duplicateNode:()=>{},copyLinkNode:()=>{},onDrop:e=>{},onDragEnd:e=>{},onDragEnter:e=>{},onDragStart:e=>{},changeHoveredNode:e=>{},changeSelectedNodeElement:e=>{}}]),vt=({children:e})=>{const n=p(),[r,i]=(e=>{const[t,n]=o(!1),[r,i]=o(Ue),[a]=o((()=>new Map)),s=t=>{var n;t.preventDefault(),t.stopPropagation();const r=t.target.closest("[data-element-id]");if(r){const{elementId:t,elementType:o}=r.dataset;if(!t||!o)return;const s=a.get(t);if(null===(n=s.data)||void 0===n?void 0:n.skipDrag)return;const l=f.findPath(e,s);i((e=>({from:e.from,to:{path:l,element:{id:t,type:o},parent:null}})))}};return[{dndState:r,disableWhileDrag:t,DRAG_MAP:a},{onDrop:t=>{try{m.withoutNormalizing(e,(()=>{var n,o;if(t.preventDefault(),t.stopPropagation(),(null===(n=r.from.element)||void 0===n?void 0:n.id)===(null===(o=r.to.element)||void 0===o?void 0:o.id))return;const i=r.from.path,s=a.get(r.to.element.id);let l=f.findPath(e,s);if(!i||!l)return;const[c,d]=m.node(e,i),[u,p]=m.parent(e,d);if(console.log("fromPath",i),console.log("fromElementPath",d),console.log("toPath",l),console.log("toPath next",b.next(l)),console.log("fromElementNode",c),console.log("parentElementNode",u),l.length>1){const t=We(c);l.length>i.length?(w.insertNodes(e,t,{at:l.length===i.length?l:b.next(l),match:e=>_.isElement(e),mode:"lowest"}),w.removeNodes(e,{at:i,match:e=>_.isElement(e)&&e.id===(null==t?void 0:t.id),mode:"lowest"})):(w.removeNodes(e,{at:i,match:e=>_.isElement(e)&&e.id===(null==t?void 0:t.id),mode:"lowest"}),w.insertNodes(e,t,{at:l.length===i.length?l:b.next(l),match:e=>_.isElement(e),mode:"lowest"})),1===u.children.length&&_.isElement(u.children[0])&&w.removeNodes(e,{at:p,match:e=>_.isElement(e)&&u.id===e.id,mode:"lowest"})}else w.moveNodes(e,{at:i,to:l,match:e=>_.isElement(e)&&_.isElement(c)&&c.type===e.type,mode:"lowest"});t.dataTransfer.clearData(),a.clear()}))}catch(e){console.error(e)}},onDragEnd:e=>{e.stopPropagation(),e.target.removeAttribute("draggable"),e.target.ondragstart=null,e.target.ondragend=null,e.target.ondragenter=null,e.target.ondragover=null,n(!1),i(Ue)},onDragEnter:s,onDragStart:(e,t)=>{n(!0),e.dataTransfer.setData("Text",""),e.dataTransfer.effectAllowed="move";const r=document.getElementById("yoopta-contenteditable");r&&(r.ondragenter=e=>s(e),r.ondragover=e=>(e.stopPropagation(),e.preventDefault(),!1),i((e=>({to:e.to,from:t}))))}}]})(n),[a,l]=o(null),[c,d]=o((()=>(({children:e})=>{if(1===e.length)return e[0];return null})(n))),[u,h]=o(null),[g,v]=o(!1),y=Object.assign({hoveredElement:c,isElementOptionsOpen:g,nodeSettingsPos:a,selectedNodeElement:u},r),O=s((()=>Object.assign({hoverIn:(e,t)=>{var n;if(g)return e.preventDefault();(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.skipSettings)||d(t)},changeSelectedNodeElement:e=>{console.log("changeSelectedNodeElement node ",e),h(e)},changeHoveredNode:e=>d(e),triggerPlusButton:e=>{m.withoutNormalizing(n,(()=>{if(!n.selection||!e)return;const t=f.findPath(n,e),r=b.next([t[0]]),o=ft(Ke());w.insertNodes(n,o,{at:r,select:!0}),d(o)}))},openNodeSettings:(e,t)=>{at(document.body,{reserveScrollBarGap:!0}),v(!0),h(t);let r=f.findPath(n,t).concat(0);if(_.isElement(null==t?void 0:t.children[0])&&(r=r.concat(0)),w.select(n,{path:r,offset:0}),d(t),e.current){const t=e.current.getBoundingClientRect();l({left:t.left+t.width+10,top:t.top})}},closeNodeSettings:()=>{st(document.body),v(!1),l(null),h(null)},deleteNode:()=>{if(c)try{m.withoutNormalizing(n,(()=>{var e;const t=f.findPath(n,c),[r,o]=m.parent(n,t);if(!t)return;let i="highest";if(_.isElement(r)){if(1===r.children.length&&_.isElement(r.children[0]))return w.removeNodes(n,{at:o,match:e=>_.isElement(e)&&e.id===r.id,mode:"highest"}),d(null),void O.closeNodeSettings();(null===(e=r.data)||void 0===e?void 0:e.depth)>0&&(i="lowest")}w.removeNodes(n,{at:t,match:e=>_.isElement(e),mode:i}),d(null),O.closeNodeSettings()}))}catch(e){console.log({error:e})}},duplicateNode:()=>{m.withoutNormalizing(n,(()=>{if(!c)return;const e=f.findPath(n,c),t=b.next(e),r=We(c);r.id=Ke(),w.insertNodes(n,r,{at:t,match:e=>_.isElement(e),mode:"highest",select:!0}),f.focus(n),d(null),O.closeNodeSettings()}))},copyLinkNode:()=>{0===window.location.hash.length?ut(`${window.location.href}#${null==c?void 0:c.id}`):ut(`${window.location.href.split("#")[0]}#${null==c?void 0:c.id}`),O.closeNodeSettings()}},i)),[c,g,r,n.children]),x=s((()=>[y,O]),[c,g,r,n.selection,n.children]);return t(gt.Provider,Object.assign({value:x},{children:e}))},yt=()=>a(gt),mt=r.createContext({marks:{},elements:{}}),bt=({children:e,plugins:n,marks:o,tools:i})=>{const a=p(),c=l(),d=e=>{if(!a.selection)return!1;const[t]=m.nodes(a,{at:m.unhangRange(a,a.selection),match:t=>!m.isEditor(t)&&_.isElement(t)&&t.type===e,mode:"highest"});return!!t},u=()=>{const e={};return n.forEach((t=>{const{createElement:n,defineElement:r,type:o,options:i}=t;S(t,["createElement","defineElement","type","options"]),e[t.type]={create:n,define:r,toggle:e=>((e,t)=>{m.withoutNormalizing(a,(()=>{var n;if(!a.selection)return;const{offset:r,path:o}=a.selection.anchor,{shouldDeleteText:i}=t||{};i&&w.delete(a,{at:{anchor:{path:o,offset:0},focus:{path:o,offset:r}}});const s=m.above(a,{at:a.selection,mode:"highest",match:e=>!m.isEditor(e)&&_.isElement(e)}),[l,c]=m.parent(a,b.parent(a.selection.anchor.path)),[d]=s||[];(null==d?void 0:d.type)!==e.type?(_.isElement(l)&&!m.isEditor(l)&&w.unwrapNodes(a,{at:c,match:e=>!m.isEditor(e)&&!O.isText(e)&&_.isElement(l)&&e.type===l.type}),null===(n=e.createElement)||void 0===n||n.call(e,a,{id:d.id})):w.setNodes(a,ft(Ke()),{mode:"highest",match:e=>!m.isEditor(e)&&_.isElement(e)})}))})(t,e),type:o,isActive:d(o),options:{displayLabel:null==i?void 0:i.displayLabel}}})),e},f=s((()=>u()),[n,a.selection]),h=e=>{const t=m.marks(a);return!!(null==t?void 0:t[e])},g=s((()=>{const e={};return null==o||o.forEach((t=>{e[t.type]={toggle:e=>((e,t=!1)=>{t&&Object.keys(m.marks(a)||{}).forEach((e=>{m.removeMark(a,e)})),h(e)?m.removeMark(a,e):m.addMark(a,e,!0)})(t.type,null==e?void 0:e.only),isActive:h(t.type)}})),e}),[o,a.selection]),v=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=S(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 c.current={elements:f,marks:g,tools:v},t(mt.Provider,Object.assign({value:c.current},{children:e}))},wt=()=>a(mt),_t=()=>a(mt).marks,Ot=()=>a(mt).elements,xt=()=>a(mt).tools;var Et="IMJgzRnZ",jt="nFfAiJWo",kt="DeARgIyF",Nt="kyuzONcU",St="_95up7F66",Dt="_9d0T-cEo";Oe(".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 Pt={position:"fixed",opacity:1,bottom:"auto",right:"auto"},At=n=>{var{onClose:r,style:i,element:a,render:s}=n,c=S(n,["onClose","style","element","render"]);const[d,u]=o({style:Pt,open:!1}),f=l(null),h=p(),g=xt(),[,v]=yt(),{ActionMenu:y}=g||{},b=!!y,w=m.isVoid(h,a),_=()=>u({style:Pt,open:!1});return t(Se,Object.assign({onClose:r},{children:t("div",Object.assign({style:i,className:_e(Et,"yoopta-element-options"),ref:f},{children:e("div",Object.assign({className:jt},{children:[d.open&&y&&t(Se,Object.assign({onClose:_},{children:y&&t(y,{style:d.style,options:{shouldDeleteText:!1},on:{toggle:()=>{_(),v.closeNodeSettings()}}})})),e("div",Object.assign({className:kt},{children:[e("button",Object.assign({type:"button",className:Nt,onClick:()=>{var e;v.deleteNode(),null===(e=c.onDelete)||void 0===e||e.call(c)}},{children:[t("div",Object.assign({className:St},{children:t(Ce,{})})),t("div",Object.assign({className:Dt},{children:"Delete"}))]})),e("button",Object.assign({type:"button",className:Nt,onClick:()=>{var e;v.duplicateNode(),null===(e=c.onDuplicate)||void 0===e||e.call(c)}},{children:[t("div",Object.assign({className:St},{children:t(Me,{})})),t("div",Object.assign({className:Dt},{children:"Duplicate"}))]})),!w&&b&&e("button",Object.assign({type:"button",className:Nt,onClick:e=>{var t;const n=f.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),u((e=>({open:!e.open,style:Object.assign(Object.assign({},e.style),o)})))}},{children:[t("div",Object.assign({className:St},{children:t(ze,{})})),t("div",Object.assign({className:Dt},{children:"Turn into"}))]})),e("button",Object.assign({type:"button",className:Nt,onClick:()=>{var e;v.copyLinkNode(),null===(e=c.onCopy)||void 0===e||e.call(c)}},{children:[t("div",Object.assign({className:St},{children:t(Re,{})})),t("div",Object.assign({className:Dt},{children:"Copy link to block"}))]}))]}))]}))}))}))};var Ct={};Object.defineProperty(Ct,"__esModule",{value:!0});for(var Tt="undefined"!=typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),Lt={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},Mt={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:Tt?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},Bt={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},Ft=1;Ft<20;Ft++)Bt["f"+Ft]=111+Ft;function zt(e,t,n){t&&!("byKey"in t)&&(n=t,t=null),Array.isArray(e)||(e=[e]);var r=e.map((function(e){return Ht(e,t)})),o=function(e){return r.some((function(t){return Rt(t,e)}))};return null==n?o:o(n)}function Ht(e,t){var n=t&&t.byKey,r={},o=(e=e.replace("++","+add")).split("+"),i=o.length;for(var a in Lt)r[Lt[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=Vt(f),g=Lt[h];if(f.length>1&&!g&&!Mt[f]&&!Bt[h])throw new TypeError('Unknown modifier: "'+f+'"');1!==i&&g||(n?r.key=h:r.which=It(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 Rt(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 It(e){return e=Vt(e),Bt[e]||e.toUpperCase().charCodeAt(0)}function Vt(e){return e=e.toLowerCase(),e=Mt[e]||e}Ct.default=zt;var Wt=Ct.isHotkey=zt,Ut=Ct.isCodeHotkey=function(e,t){return zt(e,t)},Zt=Ct.isKeyHotkey=function(e,t){return zt(e,{byKey:!0},t)};Ct.parseHotkey=Ht,Ct.compareHotkey=Rt,Ct.toKeyCode=It,Ct.toKeyName=Vt;const $t=({children:e,fallback:t=null})=>{const[n,r]=o(!1);return i((()=>r(!0)),[]),n?e:t};
|
|
7
|
+
we={get exports(){return _e},set exports(e){_e=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(" ")}we.exports?(t.default=t,we.exports=t):window.classNames=t}();var Oe=_e;function xe(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 Ee="QEROK9NJ",je="ZLDKsGEc",ke="_0wBAdXIb",Ne="P40m4iJS",Se="_7iHqOybQ";xe(".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 De=({children:n,onClose:r})=>{const[o]=i((()=>document.createElement("div")));return a((()=>(o.className="yoopta-overlay",document.body.appendChild(o),()=>{document.body.removeChild(o)})),[o]),f(e("div",Object.assign({className:Ee},{children:[t("div",{className:je}),e("div",Object.assign({className:ke},{children:[t("div",{className:Ne,onClick:r}),t("div",Object.assign({className:Se,onClick:e=>e.stopPropagation()},{children:n}))]}))]})),o)};var Pe;function Ae(){return Ae=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},Ae.apply(this,arguments)}var Ce,Te=function(e){return r.createElement("svg",Ae({viewBox:"0 0 16 16",className:"trash_svg__trash",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Pe||(Pe=r.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 Le(){return Le=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},Le.apply(this,arguments)}var Me,Be=function(e){return r.createElement("svg",Le({viewBox:"0 0 16 16",className:"duplicate_svg__duplicate",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Ce||(Ce=r.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 Fe(){return Fe=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},Fe.apply(this,arguments)}var ze,He=function(e){return r.createElement("svg",Fe({viewBox:"0 0 16 16",className:"turn_svg__loop",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Me||(Me=r.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 Re(){return Re=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},Re.apply(this,arguments)}var Ie=function(e){return r.createElement("svg",Re({viewBox:"0 0 16 16",className:"copy_svg__link",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),ze||(ze=r.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"})))},Ve={};!function(e,t){var n="__lodash_hash_undefined__",r=9007199254740991,o="[object Arguments]",i="[object Boolean]",a="[object Date]",s="[object Function]",l="[object GeneratorFunction]",c="[object Map]",d="[object Number]",u="[object Object]",f="[object Promise]",p="[object RegExp]",h="[object Set]",g="[object String]",v="[object Symbol]",y="[object WeakMap]",m="[object ArrayBuffer]",b="[object DataView]",w="[object Float32Array]",_="[object Float64Array]",O="[object Int8Array]",x="[object Int16Array]",E="[object Int32Array]",j="[object Uint8Array]",k="[object Uint8ClampedArray]",N="[object Uint16Array]",S="[object Uint32Array]",D=/\w*$/,P=/^\[object .+?Constructor\]$/,C=/^(?:0|[1-9]\d*)$/,T={};T[o]=T["[object Array]"]=T[m]=T[b]=T[i]=T[a]=T[w]=T[_]=T[O]=T[x]=T[E]=T[c]=T[d]=T[u]=T[p]=T[h]=T[g]=T[v]=T[j]=T[k]=T[N]=T[S]=!0,T["[object Error]"]=T[s]=T[y]=!1;var L="object"==typeof A&&A&&A.Object===Object&&A,M="object"==typeof self&&self&&self.Object===Object&&self,B=L||M||Function("return this")(),F=t&&!t.nodeType&&t,z=F&&e&&!e.nodeType&&e,H=z&&z.exports===F;function R(e,t){return e.set(t[0],t[1]),e}function I(e,t){return e.add(t),e}function V(e,t,n,r){var o=-1,i=e?e.length:0;for(r&&i&&(n=e[++o]);++o<i;)n=t(n,e[o],o,e);return n}function W(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function U(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function Z(e,t){return function(n){return e(t(n))}}function $(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var q=Array.prototype,K=Function.prototype,G=Object.prototype,J=B["__core-js_shared__"],X=function(){var e=/[^.]+$/.exec(J&&J.keys&&J.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Q=K.toString,Y=G.hasOwnProperty,ee=G.toString,te=RegExp("^"+Q.call(Y).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ne=H?B.Buffer:void 0,re=B.Symbol,oe=B.Uint8Array,ie=Z(Object.getPrototypeOf,Object),ae=Object.create,se=G.propertyIsEnumerable,le=q.splice,ce=Object.getOwnPropertySymbols,de=ne?ne.isBuffer:void 0,ue=Z(Object.keys,Object),fe=Fe(B,"DataView"),pe=Fe(B,"Map"),he=Fe(B,"Promise"),ge=Fe(B,"Set"),ve=Fe(B,"WeakMap"),ye=Fe(Object,"create"),me=Ve(fe),be=Ve(pe),we=Ve(he),_e=Ve(ge),Oe=Ve(ve),xe=re?re.prototype:void 0,Ee=xe?xe.valueOf:void 0;function je(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ke(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Ne(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Se(e){this.__data__=new ke(e)}function De(e,t){var n=Ue(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&Ze(e)}(e)&&Y.call(e,"callee")&&(!se.call(e,"callee")||ee.call(e)==o)}(e)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],r=n.length,i=!!r;for(var a in e)!t&&!Y.call(e,a)||i&&("length"==a||Re(a,r))||n.push(a);return n}function Pe(e,t,n){var r=e[t];Y.call(e,t)&&We(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function Ae(e,t){for(var n=e.length;n--;)if(We(e[n][0],t))return n;return-1}function Ce(e,t,n,r,f,y,P){var A;if(r&&(A=y?r(e,f,y,P):r(e)),void 0!==A)return A;if(!Ke(e))return e;var C=Ue(e);if(C){if(A=function(e){var t=e.length,n=e.constructor(t);t&&"string"==typeof e[0]&&Y.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!t)return function(e,t){var n=-1,r=e.length;t||(t=Array(r));for(;++n<r;)t[n]=e[n];return t}(e,A)}else{var L=He(e),M=L==s||L==l;if($e(e))return function(e,t){if(t)return e.slice();var n=new e.constructor(e.length);return e.copy(n),n}(e,t);if(L==u||L==o||M&&!y){if(W(e))return y?e:{};if(A=function(e){return"function"!=typeof e.constructor||Ie(e)?{}:(t=ie(e),Ke(t)?ae(t):{});var t}(M?{}:e),!t)return function(e,t){return Me(e,ze(e),t)}(e,function(e,t){return e&&Me(t,Ge(t),e)}(A,e))}else{if(!T[L])return y?e:{};A=function(e,t,n,r){var o=e.constructor;switch(t){case m:return Le(e);case i:case a:return new o(+e);case b:return function(e,t){var n=t?Le(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,r);case w:case _:case O:case x:case E:case j:case k:case N:case S:return function(e,t){var n=t?Le(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}(e,r);case c:return function(e,t,n){var r=t?n(U(e),!0):U(e);return V(r,R,new e.constructor)}(e,r,n);case d:case g:return new o(e);case p:return function(e){var t=new e.constructor(e.source,D.exec(e));return t.lastIndex=e.lastIndex,t}(e);case h:return function(e,t,n){var r=t?n($(e),!0):$(e);return V(r,I,new e.constructor)}(e,r,n);case v:return s=e,Ee?Object(Ee.call(s)):{}}var s}(e,L,Ce,t)}}P||(P=new Se);var B=P.get(e);if(B)return B;if(P.set(e,A),!C)var F=n?function(e){return function(e,t,n){var r=t(e);return Ue(e)?r:function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}(r,n(e))}(e,Ge,ze)}(e):Ge(e);return function(e,t){for(var n=-1,r=e?e.length:0;++n<r&&!1!==t(e[n],n,e););}(F||e,(function(o,i){F&&(o=e[i=o]),Pe(A,i,Ce(o,t,n,r,i,e,P))})),A}function Te(e){return!(!Ke(e)||(t=e,X&&X in t))&&(qe(e)||W(e)?te:P).test(Ve(e));var t}function Le(e){var t=new e.constructor(e.byteLength);return new oe(t).set(new oe(e)),t}function Me(e,t,n,r){n||(n={});for(var o=-1,i=t.length;++o<i;){var a=t[o],s=r?r(n[a],e[a],a,n,e):void 0;Pe(n,a,void 0===s?e[a]:s)}return n}function Be(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function Fe(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Te(n)?n:void 0}je.prototype.clear=function(){this.__data__=ye?ye(null):{}},je.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},je.prototype.get=function(e){var t=this.__data__;if(ye){var r=t[e];return r===n?void 0:r}return Y.call(t,e)?t[e]:void 0},je.prototype.has=function(e){var t=this.__data__;return ye?void 0!==t[e]:Y.call(t,e)},je.prototype.set=function(e,t){return this.__data__[e]=ye&&void 0===t?n:t,this},ke.prototype.clear=function(){this.__data__=[]},ke.prototype.delete=function(e){var t=this.__data__,n=Ae(t,e);return!(n<0)&&(n==t.length-1?t.pop():le.call(t,n,1),!0)},ke.prototype.get=function(e){var t=this.__data__,n=Ae(t,e);return n<0?void 0:t[n][1]},ke.prototype.has=function(e){return Ae(this.__data__,e)>-1},ke.prototype.set=function(e,t){var n=this.__data__,r=Ae(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Ne.prototype.clear=function(){this.__data__={hash:new je,map:new(pe||ke),string:new je}},Ne.prototype.delete=function(e){return Be(this,e).delete(e)},Ne.prototype.get=function(e){return Be(this,e).get(e)},Ne.prototype.has=function(e){return Be(this,e).has(e)},Ne.prototype.set=function(e,t){return Be(this,e).set(e,t),this},Se.prototype.clear=function(){this.__data__=new ke},Se.prototype.delete=function(e){return this.__data__.delete(e)},Se.prototype.get=function(e){return this.__data__.get(e)},Se.prototype.has=function(e){return this.__data__.has(e)},Se.prototype.set=function(e,t){var n=this.__data__;if(n instanceof ke){var r=n.__data__;if(!pe||r.length<199)return r.push([e,t]),this;n=this.__data__=new Ne(r)}return n.set(e,t),this};var ze=ce?Z(ce,Object):function(){return[]},He=function(e){return ee.call(e)};function Re(e,t){return!!(t=null==t?r:t)&&("number"==typeof e||C.test(e))&&e>-1&&e%1==0&&e<t}function Ie(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||G)}function Ve(e){if(null!=e){try{return Q.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function We(e,t){return e===t||e!=e&&t!=t}(fe&&He(new fe(new ArrayBuffer(1)))!=b||pe&&He(new pe)!=c||he&&He(he.resolve())!=f||ge&&He(new ge)!=h||ve&&He(new ve)!=y)&&(He=function(e){var t=ee.call(e),n=t==u?e.constructor:void 0,r=n?Ve(n):void 0;if(r)switch(r){case me:return b;case be:return c;case we:return f;case _e:return h;case Oe:return y}return t});var Ue=Array.isArray;function Ze(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r}(e.length)&&!qe(e)}var $e=de||function(){return!1};function qe(e){var t=Ke(e)?ee.call(e):"";return t==s||t==l}function Ke(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ge(e){return Ze(e)?De(e):function(e){if(!Ie(e))return ue(e);var t=[];for(var n in Object(e))Y.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return Ce(e,!0,!0)}}({get exports(){return Ve},set exports(e){Ve=e}},Ve);var We=Ve;function Ue(e){return"function"==typeof window.structuredClone?window.structuredClone(e):We(e)}const Ze={from:{path:null,element:null,parent:null},to:{path:null,element:null,parent:null}};let $e,qe,Ke=(e=21)=>{var t;t=e-=0,!$e||$e.length<t?($e=Buffer.allocUnsafe(128*t),S.randomFillSync($e),qe=0):qe+t>$e.length&&(S.randomFillSync($e),qe=0),qe+=t;let n="";for(let t=qe-e;t<qe;t++)n+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&$e[t]];return n};const Ge=()=>{var e;return"undefined"==typeof window?Ke():"function"!=typeof(null===(e=window.crypto)||void 0===e?void 0:e.randomUUID)?function(){let e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}():Ke()};var Je=!1;if("undefined"!=typeof window){var Xe={get passive(){Je=!0}};window.addEventListener("testPassive",null,Xe),window.removeEventListener("testPassive",null,Xe)}var Qe="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),Ye=[],et=!1,tt=-1,nt=void 0,rt=void 0,ot=void 0,it=function(e){return Ye.some((function(t){return!(!t.options.allowTouchMove||!t.options.allowTouchMove(e))}))},at=function(e){var t=e||window.event;return!!it(t.target)||(t.touches.length>1||(t.preventDefault&&t.preventDefault(),!1))},st=function(e,t){if(e){if(!Ye.some((function(t){return t.targetElement===e}))){var n={targetElement:e,options:t||{}};Ye=[].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(Ye),[n]),Qe?window.requestAnimationFrame((function(){if(void 0===rt){rt={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var e=window,t=e.scrollY,n=e.scrollX,r=e.innerHeight;document.body.style.position="fixed",document.body.style.top=-t,document.body.style.left=-n,setTimeout((function(){return window.requestAnimationFrame((function(){var e=r-window.innerHeight;e&&t>=r&&(document.body.style.top=-(t+e))}))}),300)}})):function(e){if(void 0===ot){var t=!!e&&!0===e.reserveScrollBarGap,n=window.innerWidth-document.documentElement.clientWidth;if(t&&n>0){var r=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);ot=document.body.style.paddingRight,document.body.style.paddingRight=r+n+"px"}}void 0===nt&&(nt=document.body.style.overflow,document.body.style.overflow="hidden")}(t),Qe&&(e.ontouchstart=function(e){1===e.targetTouches.length&&(tt=e.targetTouches[0].clientY)},e.ontouchmove=function(t){1===t.targetTouches.length&&function(e,t){var n=e.targetTouches[0].clientY-tt;!it(e.target)&&(t&&0===t.scrollTop&&n>0||function(e){return!!e&&e.scrollHeight-e.scrollTop<=e.clientHeight}(t)&&n<0?at(e):e.stopPropagation())}(t,e)},et||(document.addEventListener("touchmove",at,Je?{passive:!1}:void 0),et=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},lt=function(e){e?(Ye=Ye.filter((function(t){return t.targetElement!==e})),Qe&&(e.ontouchstart=null,e.ontouchmove=null,et&&0===Ye.length&&(document.removeEventListener("touchmove",at,Je?{passive:!1}:void 0),et=!1)),Qe?function(){if(void 0!==rt){var e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);document.body.style.position=rt.position,document.body.style.top=rt.top,document.body.style.left=rt.left,window.scrollTo(t,e),rt=void 0}}():(void 0!==ot&&(document.body.style.paddingRight=ot,ot=void 0),void 0!==nt&&(document.body.style.overflow=nt,nt=void 0))):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")},ct=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],r=0;r<e.rangeCount;r++)n.push(e.getRangeAt(r));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEach((function(t){e.addRange(t)})),t&&t.focus()}},dt={"text/plain":"Text","text/html":"Url",default:"Text"};var ut=function(e,t){var n,r,o,i,a,s,l=!1;t||(t={}),n=t.debug||!1;try{if(o=ct(),i=document.createRange(),a=document.getSelection(),(s=document.createElement("span")).textContent=e,s.ariaHidden="true",s.style.all="unset",s.style.position="fixed",s.style.top=0,s.style.clip="rect(0, 0, 0, 0)",s.style.whiteSpace="pre",s.style.webkitUserSelect="text",s.style.MozUserSelect="text",s.style.msUserSelect="text",s.style.userSelect="text",s.addEventListener("copy",(function(r){if(r.stopPropagation(),t.format)if(r.preventDefault(),void 0===r.clipboardData){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var o=dt[t.format]||dt.default;window.clipboardData.setData(o,e)}else r.clipboardData.clearData(),r.clipboardData.setData(t.format,e);t.onCopy&&(r.preventDefault(),t.onCopy(r.clipboardData))})),document.body.appendChild(s),i.selectNodeContents(s),a.addRange(i),!document.execCommand("copy"))throw new Error("copy command was unsuccessful");l=!0}catch(o){n&&console.error("unable to copy using execCommand: ",o),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),l=!0}catch(o){n&&console.error("unable to copy using clipboardData: ",o),n&&console.error("falling back to prompt"),r=function(e){var t=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return e.replace(/#{\s*key\s*}/g,t)}("message"in t?t.message:"Copy to clipboard: #{key}, Enter"),window.prompt(r,e)}}finally{a&&("function"==typeof a.removeRange?a.removeRange(i):a.removeAllRanges()),s&&document.body.removeChild(s),o()}return l};const ft=e=>({id:e,type:"paragraph",nodeType:"block",children:[{text:""}]});function pt(e,t,n=!1){n&&Object.keys(b.marks(e)||{}).forEach((t=>{b.removeMark(e,t)})),!function(e,t){const n=b.marks(e);return!!(null==n?void 0:n[t])}(e,t)?b.addMark(e,t,!0):b.removeMark(e,t)}const ht={hoveredElement:null,isElementOptionsOpen:!1,nodeSettingsPos:null,dndState:Ze,disableWhileDrag:!1,DRAG_MAP:new Map,selectedNodeElement:null},gt=o.createContext([ht,{openNodeSettings:(e,t)=>{},closeNodeSettings:()=>{},hoverIn:(e,t)=>{},triggerPlusButton:e=>{},deleteNode:()=>{},duplicateNode:()=>{},copyLinkNode:()=>{},onDrop:e=>{},onDragEnd:e=>{},onDragEnter:e=>{},onDragStart:e=>{},changeHoveredNode:e=>{},changeSelectedNodeElement:e=>{}}]),vt=({children:e})=>{const n=h(),[r,o]=(e=>{const[t,n]=i(!1),[r,o]=i(Ze),[a]=i((()=>new Map)),s=t=>{var n;t.preventDefault(),t.stopPropagation();const r=t.target.closest("[data-element-id]");if(r){const{elementId:t,elementType:i}=r.dataset;if(!t||!i)return;const s=a.get(t);if(null===(n=s.data)||void 0===n?void 0:n.skipDrag)return;const l=p.findPath(e,s);o((e=>({from:e.from,to:{path:l,element:{id:t,type:i},parent:null}})))}};return[{dndState:r,disableWhileDrag:t,DRAG_MAP:a},{onDrop:t=>{try{b.withoutNormalizing(e,(()=>{var n,o;if(t.preventDefault(),t.stopPropagation(),(null===(n=r.from.element)||void 0===n?void 0:n.id)===(null===(o=r.to.element)||void 0===o?void 0:o.id))return;const i=r.from.path,s=a.get(r.to.element.id);let l=p.findPath(e,s);if(!i||!l)return;const[c,d]=b.node(e,i),[u,f]=b.parent(e,d);if(console.log("fromPath",i),console.log("fromElementPath",d),console.log("toPath",l),console.log("toPath next",w.next(l)),console.log("fromElementNode",c),console.log("parentElementNode",u),l.length>1){const t=Ue(c);l.length>i.length?(_.insertNodes(e,t,{at:l.length===i.length?l:w.next(l),match:e=>O.isElement(e),mode:"lowest"}),_.removeNodes(e,{at:i,match:e=>O.isElement(e)&&e.id===(null==t?void 0:t.id),mode:"lowest"})):(_.removeNodes(e,{at:i,match:e=>O.isElement(e)&&e.id===(null==t?void 0:t.id),mode:"lowest"}),_.insertNodes(e,t,{at:l.length===i.length?l:w.next(l),match:e=>O.isElement(e),mode:"lowest"})),1===u.children.length&&O.isElement(u.children[0])&&_.removeNodes(e,{at:f,match:e=>O.isElement(e)&&u.id===e.id,mode:"lowest"})}else _.moveNodes(e,{at:i,to:l,match:e=>O.isElement(e)&&O.isElement(c)&&c.type===e.type,mode:"lowest"});t.dataTransfer.clearData(),a.clear()}))}catch(e){console.error(e)}},onDragEnd:e=>{e.stopPropagation(),e.target.removeAttribute("draggable"),e.target.ondragstart=null,e.target.ondragend=null,e.target.ondragenter=null,e.target.ondragover=null,n(!1),o(Ze)},onDragEnter:s,onDragStart:(e,t)=>{n(!0),e.dataTransfer.setData("Text",""),e.dataTransfer.effectAllowed="move";const r=document.getElementById("yoopta-contenteditable");r&&(r.ondragenter=e=>s(e),r.ondragover=e=>(e.stopPropagation(),e.preventDefault(),!1),o((e=>({to:e.to,from:t}))))}}]})(n),[a,s]=i(null),[c,d]=i((()=>(({children:e})=>{if(1===e.length)return e[0];return null})(n))),[u,f]=i(null),[g,v]=i(!1),y=Object.assign({hoveredElement:c,isElementOptionsOpen:g,nodeSettingsPos:a,selectedNodeElement:u},r),m=l((()=>Object.assign({hoverIn:(e,t)=>{var n;if(g)return e.preventDefault();(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.skipSettings)||d(t)},changeSelectedNodeElement:e=>{console.log("changeSelectedNodeElement node ",e),f(e)},changeHoveredNode:e=>d(e),triggerPlusButton:e=>{b.withoutNormalizing(n,(()=>{if(!n.selection||!e)return;const t=p.findPath(n,e),r=w.next([t[0]]),o=ft(Ge());_.insertNodes(n,o,{at:r,select:!0}),d(o)}))},openNodeSettings:(e,t)=>{st(document.body,{reserveScrollBarGap:!0}),v(!0),f(t);let r=p.findPath(n,t).concat(0);if(O.isElement(null==t?void 0:t.children[0])&&(r=r.concat(0)),_.select(n,{path:r,offset:0}),d(t),e.current){const t=e.current.getBoundingClientRect();s({left:t.left+t.width+10,top:t.top})}},closeNodeSettings:()=>{lt(document.body),v(!1),s(null),f(null)},deleteNode:()=>{if(c)try{b.withoutNormalizing(n,(()=>{var e;const t=p.findPath(n,c),[r,o]=b.parent(n,t);if(!t)return;let i="highest";if(O.isElement(r)){if(1===r.children.length&&O.isElement(r.children[0]))return _.removeNodes(n,{at:o,match:e=>O.isElement(e)&&e.id===r.id,mode:"highest"}),d(null),void m.closeNodeSettings();(null===(e=r.data)||void 0===e?void 0:e.depth)>0&&(i="lowest")}_.removeNodes(n,{at:t,match:e=>O.isElement(e),mode:i}),d(null),m.closeNodeSettings()}))}catch(e){console.log({error:e})}},duplicateNode:()=>{b.withoutNormalizing(n,(()=>{if(!c)return;const e=p.findPath(n,c),t=w.next(e),r=Ue(c);r.id=Ge(),_.insertNodes(n,r,{at:t,match:e=>O.isElement(e),mode:"highest",select:!0}),p.focus(n),d(null),m.closeNodeSettings()}))},copyLinkNode:()=>{0===window.location.hash.length?ut(`${window.location.href}#${null==c?void 0:c.id}`):ut(`${window.location.href.split("#")[0]}#${null==c?void 0:c.id}`),m.closeNodeSettings()}},o)),[c,g,r,n.children]),x=l((()=>[y,m]),[c,g,r,n.selection,n.children]);return t(gt.Provider,Object.assign({value:x},{children:e}))},yt=()=>s(gt),mt=o.createContext({marks:{},elements:{}}),bt=({children:e,plugins:n,marks:r,tools:i})=>{const a=h(),s=c(),d=e=>{if(!a.selection)return!1;const[t]=b.nodes(a,{at:b.unhangRange(a,a.selection),match:t=>!b.isEditor(t)&&O.isElement(t)&&t.type===e,mode:"highest"});return!!t},u=()=>{const e={};return n.forEach((t=>{const{createElement:n,defineElement:r,type:o,options:i}=t;D(t,["createElement","defineElement","type","options"]),e[t.type]={create:n,define:r,toggle:e=>((e,t)=>{b.withoutNormalizing(a,(()=>{var n;if(!a.selection)return;const{offset:r,path:o}=a.selection.anchor,{shouldDeleteText:i}=t||{};i&&_.delete(a,{at:{anchor:{path:o,offset:0},focus:{path:o,offset:r}}});const s=b.above(a,{at:a.selection,mode:"highest",match:e=>!b.isEditor(e)&&O.isElement(e)}),[l,c]=b.parent(a,w.parent(a.selection.anchor.path)),[d]=s||[];(null==d?void 0:d.type)!==e.type?(O.isElement(l)&&!b.isEditor(l)&&_.unwrapNodes(a,{at:c,match:e=>!b.isEditor(e)&&!x.isText(e)&&O.isElement(l)&&e.type===l.type}),null===(n=e.createElement)||void 0===n||n.call(e,a,{id:d.id})):_.setNodes(a,ft(Ge()),{mode:"highest",match:e=>!b.isEditor(e)&&O.isElement(e)})}))})(t,e),type:o,isActive:d(o),options:{displayLabel:null==i?void 0:i.displayLabel}}})),e},f=l((()=>u()),[n,a.selection]),p=e=>{const t=b.marks(a);return!!(null==t?void 0:t[e])},g=l((()=>{const e={};return null==r||r.forEach((t=>{e[t.type]={toggle:e=>((e,t=!1)=>{t&&Object.keys(b.marks(a)||{}).forEach((e=>{b.removeMark(a,e)})),p(e)?b.removeMark(a,e):b.addMark(a,e,!0)})(t.type,null==e?void 0:e.only),isActive:p(t.type)}})),e}),[r,a.selection]),v=l((()=>{const e=Object.keys(i||{});if(0===e.length)return;const t={};return e.forEach((e=>{const r=null==i?void 0:i[e];r&&o.isValidElement(r)&&(t[e]=e=>{var{style:t,className:i}=e,a=D(e,["style","className"]);return o.cloneElement(r,Object.assign(Object.assign({style:t,className:i,plugins:n,fromHook:!0},null==r?void 0:r.props),a))})})),t}),[i]);return s.current={elements:f,marks:g,tools:v},t(mt.Provider,Object.assign({value:s.current},{children:e}))},wt=()=>s(mt),_t=()=>s(mt).marks,Ot=()=>s(mt).elements,xt=()=>s(mt).tools;var Et="IMJgzRnZ",jt="nFfAiJWo",kt="DeARgIyF",Nt="kyuzONcU",St="_95up7F66",Dt="_9d0T-cEo";xe(".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 Pt={position:"fixed",opacity:1,bottom:"auto",right:"auto"},At=n=>{var{onClose:r,style:o,element:a,render:s}=n,l=D(n,["onClose","style","element","render"]);const[d,u]=i({style:Pt,open:!1}),f=c(null),p=h(),g=xt(),[,v]=yt(),{ActionMenu:y}=g||{},m=!!y,w=b.isVoid(p,a),_=()=>u({style:Pt,open:!1});return t(De,Object.assign({onClose:r},{children:t("div",Object.assign({style:o,className:Oe(Et,"yoopta-element-options"),ref:f},{children:e("div",Object.assign({className:jt},{children:[d.open&&y&&t(De,Object.assign({onClose:_},{children:y&&t(y,{style:d.style,options:{shouldDeleteText:!1},on:{toggle:()=>{_(),v.closeNodeSettings()}}})})),e("div",Object.assign({className:kt},{children:[e("button",Object.assign({type:"button",className:Nt,onClick:()=>{var e;v.deleteNode(),null===(e=l.onDelete)||void 0===e||e.call(l)}},{children:[t("div",Object.assign({className:St},{children:t(Te,{})})),t("div",Object.assign({className:Dt},{children:"Delete"}))]})),e("button",Object.assign({type:"button",className:Nt,onClick:()=>{var e;v.duplicateNode(),null===(e=l.onDuplicate)||void 0===e||e.call(l)}},{children:[t("div",Object.assign({className:St},{children:t(Be,{})})),t("div",Object.assign({className:Dt},{children:"Duplicate"}))]})),!w&&m&&e("button",Object.assign({type:"button",className:Nt,onClick:e=>{var t;const n=f.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),u((e=>({open:!e.open,style:Object.assign(Object.assign({},e.style),o)})))}},{children:[t("div",Object.assign({className:St},{children:t(He,{})})),t("div",Object.assign({className:Dt},{children:"Turn into"}))]})),e("button",Object.assign({type:"button",className:Nt,onClick:()=>{var e;v.copyLinkNode(),null===(e=l.onCopy)||void 0===e||e.call(l)}},{children:[t("div",Object.assign({className:St},{children:t(Ie,{})})),t("div",Object.assign({className:Dt},{children:"Copy link to block"}))]}))]}))]}))}))}))};var Ct={};Object.defineProperty(Ct,"__esModule",{value:!0});for(var Tt="undefined"!=typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),Lt={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},Mt={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:Tt?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},Bt={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},Ft=1;Ft<20;Ft++)Bt["f"+Ft]=111+Ft;function zt(e,t,n){t&&!("byKey"in t)&&(n=t,t=null),Array.isArray(e)||(e=[e]);var r=e.map((function(e){return Ht(e,t)})),o=function(e){return r.some((function(t){return Rt(t,e)}))};return null==n?o:o(n)}function Ht(e,t){var n=t&&t.byKey,r={},o=(e=e.replace("++","+add")).split("+"),i=o.length;for(var a in Lt)r[Lt[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=Vt(f),g=Lt[h];1!==i&&g||(n?r.key=h:r.which=It(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 Rt(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 It(e){return e=Vt(e),Bt[e]||e.toUpperCase().charCodeAt(0)}function Vt(e){return e=e.toLowerCase(),e=Mt[e]||e}Ct.default=zt;var Wt=Ct.isHotkey=zt,Ut=Ct.isCodeHotkey=function(e,t){return zt(e,t)},Zt=Ct.isKeyHotkey=function(e,t){return zt(e,{byKey:!0},t)};Ct.parseHotkey=Ht,Ct.compareHotkey=Rt,Ct.toKeyCode=It,Ct.toKeyName=Vt;const $t=({children:e,fallback:t=null})=>{const[n,r]=i(!1);return a((()=>r(!0)),[]),n?e:t};
|
|
8
8
|
/*!
|
|
9
9
|
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
10
10
|
*
|
|
11
11
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
12
12
|
* Released under the MIT License.
|
|
13
|
-
*/function qt(e){return"[object Object]"===Object.prototype.toString.call(e)}function Kt(e){var t,n;return!1!==qt(e)&&(void 0===(t=e.constructor)||!1!==qt(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))}var Gt={isHistory:e=>Kt(e)&&Array.isArray(e.redos)&&Array.isArray(e.undos)&&(0===e.redos.length||x.isOperationList(e.redos[0]))&&(0===e.undos.length||x.isOperationList(e.undos[0]))},Jt=new WeakMap,Xt=new WeakMap,Qt={isHistoryEditor:e=>Gt.isHistory(e.history)&&m.isEditor(e),isMerging:e=>Xt.get(e),isSaving:e=>Jt.get(e),redo(e){e.redo()},undo(e){e.undo()},withoutMerging(e,t){var n=Qt.isMerging(e);Xt.set(e,!1),t(),Xt.set(e,n)},withoutSaving(e,t){var n=Qt.isSaving(e);Jt.set(e,!1),t(),Jt.set(e,n)}},Yt=(e,t)=>"set_selection"===e.type||(!(!t||"insert_text"!==e.type||"insert_text"!==t.type||e.offset!==t.offset+t.text.length||!b.equals(e.path,t.path))||!(!t||"remove_text"!==e.type||"remove_text"!==t.type||e.offset+e.text.length!==t.offset||!b.equals(e.path,t.path))),en=(e,t)=>"set_selection"!==e.type||null!=e.properties&&null!=e.newProperties,tn=(e,t)=>!(!t||"set_selection"!==e.type||"set_selection"!==t.type),nn=e=>"set_selection"!==e.type;function rn(e){return!!Array.isArray(e)&&0!==e.length}const on="yoopta-content";var an="u-OdDyDx",sn="xA0VqV0c";Oe(".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 ln={margin:"1px 0",whiteSpace:"pre-wrap",wordBreak:"break-word",color:"inherit",fontSize:"inherit",lineHeight:"inherit",fontWeight:"inherit"},cn=c((({attributes:e,children:n,placeholder:r,leaf:o})=>{const i=h();return t("span",Object.assign({},e,{"data-placeholder":r,style:ln,className:_e({[an]:o.withPlaceholder&&r&&i,[sn]:o.selection})},{children:n}))}));cn.displayName="TextLeaf";var dn;function un(){return un=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},un.apply(this,arguments)}var fn,pn=function(e){return n.createElement("svg",un({viewBox:"0 0 10 10",fill:"currentColor",style:{width:14,height:14,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),dn||(dn=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 hn(){return hn=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},hn.apply(this,arguments)}var gn=function(e){return n.createElement("svg",hn({viewBox:"0 0 16 16",fill:"currentColor",style:{width:16,height:16,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),fn||(fn=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"})))},vn="yCQ-VdE5",yn="b--398nS",mn="_6VhqH6wy",bn="k9i48GWd",wn="TNeDy6y5",_n="jVfkavqE",On="_87oFW01f",xn="oz5S7EmO";Oe('.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 En=({element:n,editor:r,values:o,handlers:i})=>{const a=l(null),{hoveredElement:s,isElementOptionsOpen:c,nodeSettingsPos:d}=o,{onDragEnd:u,onDragStart:p,openNodeSettings:h,closeNodeSettings:g,triggerPlusButton:v}=i,y=e=>{e.stopPropagation();const t=a.current,o=document.querySelector(`[data-element-id="${null==n?void 0:n.id}"]`),i=f.findPath(r,n),s=m.parent(r,i);_.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=u))},b=(null==s?void 0:s.id)===n.id;return e("div",Object.assign({contentEditable:!1,className:_e(vn,{[yn]:b},"yoopta-element-actions")},{children:[b&&c&&t(At,{element:n,style:d||void 0,onClose:g}),t("button",Object.assign({type:"button",onMouseDown:y,className:_e(mn,bn,"yoopta-element-actions-plus"),onClick:()=>v(n)},{children:t(gn,{})})),t("button",Object.assign({type:"button",onMouseDown:y,className:_e(mn,"yoopta-element-actions-drag"),onClick:()=>h(a,n),ref:a},{children:t(pn,{})}))]}))},jn=({children:n,element:r,attributes:o,nodeType:i,render:a,HTMLAttributes:l})=>{var c,d;const u=p(),[f,h]=yt(),g="inline"===i,{hoverIn:v,onDrop:y}=h,{dndState:m,DRAG_MAP:b}=f,w=s((()=>{var e,t;if(null===m.from.element||null===m.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]),_=null===(c=r.data)||void 0===c?void 0:c.skipSettings,{isDragging:O,isDragOver:x,isDragSelf:E}=w,j={opacity:O?.7:1};return b.set(r.id,r),g?a({attributes:o,element:r,children:n,HTMLAttributes:l}):e("div",Object.assign({"data-element-id":r.id,"data-element-type":r.type,onMouseEnter:e=>{_||v(e,r)},onDrop:y,className:_e(wn,{[_n]:x,[On]:E}),style:j},o,{children:[_?null:t(En,{editor:u,element:r,handlers:h,values:f}),a({attributes:o,element:r,children:n,HTMLAttributes:l}),(null===(d=f.selectedNodeElement)||void 0===d?void 0:d.id)===r.id&&t("div",{className:_e(xn,"yoopta-selected-node-element")})]}))};jn.displayName="ElementWrapper";const kn={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"},Nn={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"},Sn={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},Dn=e=>{const t=kn[e],n=Nn[e],r=Sn[e],o=t&&Zt(t),i=n&&Zt(n),a=r&&Zt(r);return e=>!(!o||!o(e))||(!(!i||!i(e))||!(!a||!a(e)))},Pn={isBold:Dn("bold"),isCompose:Dn("compose"),isArrowLeft:Dn("arrowLeft"),isArrowRight:Dn("arrowRight"),isArrowUp:Dn("arrowUp"),isArrowDown:Dn("arrowDown"),isDeleteBackward:Dn("deleteBackward"),isDeleteForward:Dn("deleteForward"),isDeleteLineBackward:Dn("deleteLineBackward"),isDeleteLineForward:Dn("deleteLineForward"),isDeleteWordBackward:Dn("deleteWordBackward"),isDeleteWordForward:Dn("deleteWordForward"),isExtendBackward:Dn("extendBackward"),isExtendForward:Dn("extendForward"),isExtendLineBackward:Dn("extendLineBackward"),isExtendLineForward:Dn("extendLineForward"),isItalic:Dn("italic"),isMoveLineBackward:Dn("moveLineBackward"),isMoveLineForward:Dn("moveLineForward"),isCtrlLeft:Dn("ctrlLeft"),isCtrlRight:Dn("ctrlRight"),isRedo:Dn("redo"),isShiftEnter:Dn("shiftEnter"),isEnter:Dn("enter"),isTransposeCharacter:Dn("transposeCharacter"),isUndo:Dn("undo"),isSpace:Dn("space"),isSelect:Dn("select"),isTab:Dn("tab"),isShiftTab:Dn("shiftTab"),isBackspace:Dn("backspace"),isCmdEnter:Dn("cmdEnter"),isCmd:Dn("cmd"),isEscape:Dn("escape"),isKekceburek:Dn("kekCeburek")},An=(e,t)=>!!((e,t)=>{const{selection:n}=e;if(!n)return!1;const[r]=Array.from(m.nodes(e,{at:m.unhangRange(e,n),match:e=>!m.isEditor(e)&&_.isElement(e)&&e.type===t}));return r})(e,t),Cn=(e,t,n="lowest")=>{var r;const o=Array.from(m.nodes(e,{match:t=>m.isEditor(e)&&_.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 Tn(e,t){var n,r;if(O.isText(e))return function(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,(e=>t[e]))}(e.text);const o=e.children.map((e=>Tn(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 Ln(e,t){return e.map((e=>Tn(e,t))).join("")}const Mn={outline:"none"},Bn={hotkeys:Pn,defaultNode:ft(Ke())},Fn=({editor:n,placeholder:r,marks:o,readOnly:a,plugins:c,className:u,PLUGINS_MAP:p})=>{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 h=l(null),[{disableWhileDrag:v},{changeHoveredNode:y}]=yt(),O=xt(),{ActionMenu:x,Toolbar:j}=O||{};console.log("tools",O);const k=v||a,N=s((()=>e=>{var r;const o=p[e.element.type],i=function(e){return"function"==typeof e.renderer?e.renderer:e.renderer.editor}(o)(n,o);return t(jn,Object.assign({element:e.element,attributes:e.attributes,nodeType:e.element.nodeType,render:i,HTMLAttributes:null===(r=o.options)||void 0===r?void 0:r.HTMLAttributes},{children:e.children}))}),[c,n]),S=s((()=>e=>{const t=[],[r,o]=e;return c.forEach((o=>{const i=o.decorator;"function"==typeof i&&_.isElement(r)&&r.type===o.type&&t.push(...i(n)(e))})),n.selection&&!m.isEditor(r)&&""===m.string(n,[o[0]])&&E.includes(n.selection,o)&&E.isCollapsed(n.selection)&&t.push(Object.assign(Object.assign({},n.selection),{withPlaceholder:!0})),t}),[c,n]),D=s((()=>e=>{var i;const a=Object.assign({},e);let s;c.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 l=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)}(l)){const e=p[null==l?void 0:l.type];s=null===(null==e?void 0:e.placeholder)?null:(null==e?void 0:e.placeholder)||r}return t(cn,Object.assign({},a,{placeholder:s}))}),[c,n]),P=s((()=>{const e=c.map((e=>Object.keys(e.events||{}))).flat().filter(((e,t,n)=>n.indexOf(e)===t)),t={};return e.forEach((e=>{t[e]=function(t){c.forEach((r=>{var o;if(null===(o=r.events)||void 0===o?void 0:o[e]){r.events[e](n,Bn)(t)}}))}})),t}),[c,n]),A=d((e=>{m.withoutNormalizing(n,(()=>{var t;if(!n.selection)return;const r=ft(Ke());null==o||o.forEach((t=>{t.hotkey&&Zt(t.hotkey)(e)&&(e.preventDefault(),pt(n,t.type,!1))})),null===(t=P.onKeyDown)||void 0===t||t.call(P,e);const i=m.above(n,{match:e=>!m.isEditor(e),mode:"lowest"});if(Pn.isEnter(e)){if(e.isDefaultPrevented())return;e.preventDefault();const t=Object.keys(m.marks(n)||{});t.length>0&&t.forEach((e=>m.removeMark(n,e)));const o=b.parent(n.selection.anchor.path),a=m.string(n,o),s=i&&i[0].type!==r.type;if(s&&0===a.length)return void w.setNodes(n,r,{at:o});if(m.isStart(n,n.selection.anchor,n.selection.anchor.path)&&s){const[e]=i;return w.setNodes(n,r,{at:o}),w.delete(n,{unit:"block"}),w.insertNodes(n,We(e),{at:b.next(o)}),void w.select(n,{path:[b.next(n.selection.anchor.path)[0]+1,0],offset:0})}return w.splitNodes(n,{always:!0}),w.setNodes(n,r),void y(r)}if(Pn.isShiftEnter(e)){if(e.isDefaultPrevented())return;e.preventDefault(),n.insertText("\n")}if(Pn.isSelect(e)){if(e.isDefaultPrevented())return;e.preventDefault();const t=m.above(n,{at:n.selection.anchor.path,match:e=>!m.isEditor(e)&&_.isElement(e)});if(!t)return;const r=m.string(n,t[1]);return E.isExpanded(n.selection)||0===r.length?void w.select(n,[]):void w.select(n,t[1])}}))}),[]);return e("div",Object.assign({id:"yoopta-editor",className:u,ref:h,onMouseDown:e=>{a||(e.preventDefault(),e.currentTarget===e.target&&n.selection&&m.withoutNormalizing(n,(()=>{const e=[n.children.length-1,0],t=Cn(n,e,"highest"),r=m.string(n,e),o={anchor:{path:e,offset:0},focus:{path:e,offset:0}};if("paragraph"===t.type&&0===r.length)return w.select(n,{path:o.anchor.path,offset:0}),y(t),f.focus(n);const i=ft(Ke());y(i),w.insertNodes(n,i,{at:[n.children.length],select:!0}),f.focus(n)})))}},{children:[!!x&&t(x,{}),!!j&&t(j,{}),t(g,Object.assign({id:"yoopta-contenteditable",renderLeaf:D,renderElement:N,readOnly:k,decorate:S,onCopy:e=>{if(!n.selection)return;const t=Ln(m.fragment(n,n.selection),n.plugins);return e.clipboardData.setData("text/html",t),e.clipboardData},autoFocus:!0,spellCheck:!0},P,{onKeyDown:A,onMouseDown:e=>{var t;null===(t=P.onMouseDown)||void 0===t||t.call(P,e),(e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()})(e)},style:Mn}))]}))};function zn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Hn=new WeakMap,Rn=new WeakMap;class In{}class Vn extends In{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 Wn extends In{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 Un=e=>Rn.get(e);function Zn(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 $n(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Zn(Object(n),!0).forEach((function(t){zn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var qn=new WeakSet,Kn=e=>{var t=[],n=e=>{if(null!=e){var r=t[t.length-1];if("string"==typeof e){var o={text:e};qn.add(o),e=o}if(O.isText(e)){var i=e;O.isText(r)&&qn.has(r)&&qn.has(i)&&O.equals(r,i,{loose:!0})?r.text+=i.text:t.push(i)}else if(_.isElement(e))t.push(e);else{if(!(e instanceof In))throw new Error("Unexpected hyperscript child object: ".concat(e));var a=t[t.length-1];O.isText(a)||(n(""),a=t[t.length-1]),e instanceof Vn?((e,t)=>{var n=e.text.length;Hn.set(e,[n,t])})(a,e):e instanceof Wn&&((e,t)=>{var n=e.text.length;Rn.set(e,[n,t])})(a,e)}}};for(var r of e.flat(1/0))n(r);return t};function Gn(e,t,n){return $n($n({},t),{},{children:Kn(n)})}function Jn(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 Xn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Jn(Object(n),!0).forEach((function(t){zn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Qn,Yn={anchor:function(e,t,n){return new Vn(t)},cursor:function(e,t,n){return[new Vn(t),new Wn(t)]},editor:(Qn=k,(e,t,n)=>{var r,o=[];for(var i of n)E.isRange(i)?r=i:o.push(i);var a,s=Kn(o),l={},c=Qn();for(var[d,u]of(Object.assign(c,t),c.children=s,j.texts(c))){var f=(a=d,Hn.get(a)),p=Un(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:E.isRange(l)&&(c.selection=l),c}),element:Gn,focus:function(e,t,n){return new Wn(t)},fragment:function(e,t,n){return Kn(n)},selection:function(e,t,n){var r=n.find((e=>e instanceof Vn)),o=n.find((e=>e instanceof Wn));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 $n({anchor:{offset:r.offset,path:r.path},focus:{offset:o.offset,path:o.path}},t)},text:function(e,t,n){var r=Kn(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:""}),!O.isText(o))throw new Error("\n The <text> hyperscript tag can only contain text content as children.");return qn.delete(o),Object.assign(o,t),o}},er=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={}),Kt(n)||(o=[n].concat(o),n={}),a(t,n,o=o.filter((e=>Boolean(e))).flat())},tr=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)=>Gn(0,Xn(Xn({},r),t),n)};for(var r in e)n(r);return t},nr=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{elements:t={}}=e,n=tr(t),r=Xn(Xn(Xn({},Yn),n),e.creators);return er(r)}();const rr={DEL:()=>({strikethrough:!0}),EM:()=>({italic:!0}),I:()=>({italic:!0}),S:()=>({strikethrough:!0}),STRONG:()=>({bold:!0}),U:()=>({underline:!0})},or=(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=>or(e,t))).flat();if(0===l.length&&(l=[{text:""}]),"BODY"===e.nodeName)return nr("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 nr("element",t,l)}}if(O.isTextList(l))return nr("element",t.P.defineElement(),l);if(rr[a]){const t=rr[a](e);return l.map((e=>O.isText(e)?nr("text",t,e):e))}return l};function ir(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 or(r.body,n)}catch(e){return console.error(e),null}}const ar=({key:e,value:n,plugins:r,marks:a,readOnly:l,onChange:c,placeholder:u,autoFocus:p=!0,offline:h,className:g,tools:N})=>{const S=function(e){return"string"==typeof e?e:on}(h),[D,P]=o((()=>function(e,t,n){const r=[{id:Ke(),type:"paragraph",children:[{text:""}]}],o=rn(n)?n:r;if(!t)return localStorage.removeItem(e),o;try{const t=JSON.parse(localStorage.getItem(e)||"[]");return rn(t)?t:o}catch(t){return localStorage.removeItem(e),r}}(S,h,n))),A=d((e=>{if(c(e),P(e),!h)return;if(M.operations.some((e=>"set_selection"!==e.type)))try{const t=JSON.stringify(e);localStorage.setItem(S,t)}catch(e){}}),[h]),C=s((()=>{const e=me(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:L}=C,M=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=ir(r,e.plugins);return console.log("fragment",t),void w.insertFragment(e,t)}t(n)},e})((e=>{const{deleteFragment:t}=e;return e.deleteFragment=()=>{const{selection:n}=e;if(!n)return;const[,r]=m.first(e,[0]),[,o]=m.last(e,[e.children.length-1]),i=m.range(e,r,o);if(E.equals(n,i))return w.removeNodes(e,{mode:"highest",hanging:!0}),void w.select(e,[0]);t()},e})((e=>{const{normalizeNode:t}=e;return e.normalizeNode=n=>{const[r]=n;if(m.isEditor(r)&&0===e.children.length){const t=ft(Ke());w.insertNodes(e,t,{at:[0]})}else t(n)},e})((e=>{const{insertBreak:t,deleteBackward:n}=e;return e.insertBreak=()=>{if(!e.selection||!E.isCollapsed(e.selection))return t();const n=b.parent(e.selection.anchor.path),r=j.get(e,n);_.isElement(r)&&m.isVoid(e,r)?m.insertNode(e,{id:Ke(),type:"paragraph",children:[{text:""}],nodeType:"block"}):t()},e.deleteBackward=t=>{if(!e.selection||!E.isCollapsed(e.selection)||0!==e.selection.anchor.offset)return n(t);const r=b.parent(e.selection.anchor.path),o=j.get(e,r);if(0===j.string(o).length&&b.hasPrevious(r)){const t=b.previous(r),n=j.get(e,t);if(_.isElement(n)&&m.isVoid(e,n))return w.removeNodes(e),w.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];Qt.withoutSaving(t,(()=>{m.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];Qt.withoutSaving(t,(()=>{m.withoutNormalizing(t,(()=>{var e=r.map(x.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=tn(e,s),c=Qt.isSaving(t),d=Qt.isMerging(t);if(null==c&&(c=en(e)),c){if(null==d&&(d=null!=a&&(0!==r.length||Yt(e,s)||l)),a&&d)l&&a.pop(),a.push(e);else{var u=[e];i.push(u)}for(;i.length>100;)i.shift();nn(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&&E.isCollapsed(i)){const{anchor:a}=i,s=m.above(e,{match:t=>_.isElement(t)&&m.isBlock(e,t),mode:"lowest"});if(!s)return;const[,l]=s,c=m.parent(e,l),[d]=c;if(_.isElement(d)&&!O.isText(d.children[0]))return t(n);const u=s?l:[],f={anchor:a,focus:m.start(e,u)},p=m.string(e,f),h=null===(r=e.shortcuts)||void 0===r?void 0:r[p];if(h)return w.select(e,f),w.delete(e),void(null===(o=h.createElement)||void 0===o||o.call(h,e))}t(n)},e})(v(k())))))));e.plugins=L;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(p)try{const[,e]=m.first(M,[0]);w.select(M,{anchor:{path:e,offset:0},focus:{path:e,offset:0}}),f.focus(M)}catch(e){}}),[p,M]),t(y,Object.assign({editor:M,initialValue:D,onChange:A},{children:t(vt,{children:t(bt,Object.assign({plugins:T,marks:a,tools:N},{children:t(Fn,{editor:M,readOnly:l,placeholder:u,plugins:T,marks:a,PLUGINS_MAP:L,className:g})}))})}),e)},sr=e=>t($t,{children:t(ar,Object.assign({},e,{value:e.value,onChange:e.onChange}))});function lr({type:e,hotkey:n,className:r,as:o}){return Object.freeze({type:e,hotkey:n,render:n=>t(o||"span",Object.assign({},n.attributes,{className:_e(r,`yoopta-leaf-${e}`)},{children:n.children}))})}function cr(e){const{element:t,HTMLAttributes:n,className:r}=e;return`yoopta-${t.type} ${(null==n?void 0:n.className)||""} ${r}`}const dr={ElementOptions:At,Overlay:Se};export{Pn as HOTKEYS,dr as UI_HELPERS,ve as YooptaPlugin,lr as createYooptaMark,ye as createYooptaPlugin,_e as cx,We as deepClone,sr as default,at as disableBodyScroll,st as enableBodyScroll,Ke as generateId,Cn as getElementByPath,cr as getElementClassname,Ut as isCodeHotkey,An as isElementActive,Wt as isHotkey,Zt as isKeyHotkey,rn as isValidYooptaNodes,me as mergePlugins,Ot as useElements,_t as useMarks,yt as useNodeElementSettings,xt as useTools,wt as useYoopta};
|
|
13
|
+
*/function qt(e){return"[object Object]"===Object.prototype.toString.call(e)}function Kt(e){var t,n;return!1!==qt(e)&&(void 0===(t=e.constructor)||!1!==qt(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))}var Gt={isHistory:e=>Kt(e)&&Array.isArray(e.redos)&&Array.isArray(e.undos)&&(0===e.redos.length||E.isOperationList(e.redos[0]))&&(0===e.undos.length||E.isOperationList(e.undos[0]))},Jt=new WeakMap,Xt=new WeakMap,Qt={isHistoryEditor:e=>Gt.isHistory(e.history)&&b.isEditor(e),isMerging:e=>Xt.get(e),isSaving:e=>Jt.get(e),redo(e){e.redo()},undo(e){e.undo()},withoutMerging(e,t){var n=Qt.isMerging(e);Xt.set(e,!1),t(),Xt.set(e,n)},withoutSaving(e,t){var n=Qt.isSaving(e);Jt.set(e,!1),t(),Jt.set(e,n)}},Yt=(e,t)=>"set_selection"===e.type||(!(!t||"insert_text"!==e.type||"insert_text"!==t.type||e.offset!==t.offset+t.text.length||!w.equals(e.path,t.path))||!(!t||"remove_text"!==e.type||"remove_text"!==t.type||e.offset+e.text.length!==t.offset||!w.equals(e.path,t.path))),en=(e,t)=>"set_selection"!==e.type||null!=e.properties&&null!=e.newProperties,tn=(e,t)=>!(!t||"set_selection"!==e.type||"set_selection"!==t.type),nn=e=>"set_selection"!==e.type;function rn(e){return!!Array.isArray(e)&&0!==e.length}var on="u-OdDyDx",an="xA0VqV0c";xe(".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 sn={margin:"1px 0",whiteSpace:"pre-wrap",wordBreak:"break-word",color:"inherit",fontSize:"inherit",lineHeight:"inherit",fontWeight:"inherit"},ln=d((({attributes:e,children:n,placeholder:r,leaf:o})=>{const i=g();return t("span",Object.assign({},e,{"data-placeholder":r,style:sn,className:Oe({[on]:o.withPlaceholder&&r&&i,[an]:o.selection})},{children:n}))}));ln.displayName="TextLeaf";var cn;function dn(){return dn=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},dn.apply(this,arguments)}var un,fn=function(e){return r.createElement("svg",dn({viewBox:"0 0 10 10",fill:"currentColor",style:{width:14,height:14,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),cn||(cn=r.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 pn(){return pn=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},pn.apply(this,arguments)}var hn=function(e){return r.createElement("svg",pn({viewBox:"0 0 16 16",fill:"currentColor",style:{width:16,height:16,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),un||(un=r.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"})))},gn="yCQ-VdE5",vn="b--398nS",yn="_6VhqH6wy",mn="k9i48GWd",bn="TNeDy6y5",wn="jVfkavqE",_n="_87oFW01f",On="oz5S7EmO";xe('.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 xn=({element:n,editor:r,values:o,handlers:i})=>{const a=c(null),{hoveredElement:s,isElementOptionsOpen:l,nodeSettingsPos:d}=o,{onDragEnd:u,onDragStart:f,openNodeSettings:h,closeNodeSettings:g,triggerPlusButton:v}=i,y=e=>{e.stopPropagation();const t=a.current,o=document.querySelector(`[data-element-id="${null==n?void 0:n.id}"]`),i=p.findPath(r,n),s=b.parent(r,i);O.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};f(e,t)},o.ondragend=u))},m=(null==s?void 0:s.id)===n.id;return e("div",Object.assign({contentEditable:!1,className:Oe(gn,{[vn]:m},"yoopta-element-actions")},{children:[m&&l&&t(At,{element:n,style:d||void 0,onClose:g}),t("button",Object.assign({type:"button",onMouseDown:y,className:Oe(yn,mn,"yoopta-element-actions-plus"),onClick:()=>v(n)},{children:t(hn,{})})),t("button",Object.assign({type:"button",onMouseDown:y,className:Oe(yn,"yoopta-element-actions-drag"),onClick:()=>h(a,n),ref:a},{children:t(fn,{})}))]}))},En=({children:n,element:r,attributes:o,nodeType:i,render:a,HTMLAttributes:s})=>{var c,d;const u=h(),[f,p]=yt(),g="inline"===i,{hoverIn:v,onDrop:y}=p,{dndState:m,DRAG_MAP:b}=f,w=l((()=>{var e,t;if(null===m.from.element||null===m.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]),_=null===(c=r.data)||void 0===c?void 0:c.skipSettings,{isDragging:O,isDragOver:x,isDragSelf:E}=w,j={opacity:O?.7:1};return b.set(r.id,r),g?a({attributes:o,element:r,children:n,HTMLAttributes:s}):e("div",Object.assign({"data-element-id":r.id,"data-element-type":r.type,onMouseEnter:e=>{_||v(e,r)},onDrop:y,className:Oe(bn,{[wn]:x,[_n]:E}),style:j},o,{children:[_?null:t(xn,{editor:u,element:r,handlers:p,values:f}),a({attributes:o,element:r,children:n,HTMLAttributes:s}),(null===(d=f.selectedNodeElement)||void 0===d?void 0:d.id)===r.id&&t("div",{className:Oe(On,"yoopta-selected-node-element")})]}))};En.displayName="ElementWrapper";const jn={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"},kn={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"},Nn={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},Sn=e=>{const t=jn[e],n=kn[e],r=Nn[e],o=t&&Zt(t),i=n&&Zt(n),a=r&&Zt(r);return e=>!(!o||!o(e))||(!(!i||!i(e))||!(!a||!a(e)))},Dn={isBold:Sn("bold"),isCompose:Sn("compose"),isArrowLeft:Sn("arrowLeft"),isArrowRight:Sn("arrowRight"),isArrowUp:Sn("arrowUp"),isArrowDown:Sn("arrowDown"),isDeleteBackward:Sn("deleteBackward"),isDeleteForward:Sn("deleteForward"),isDeleteLineBackward:Sn("deleteLineBackward"),isDeleteLineForward:Sn("deleteLineForward"),isDeleteWordBackward:Sn("deleteWordBackward"),isDeleteWordForward:Sn("deleteWordForward"),isExtendBackward:Sn("extendBackward"),isExtendForward:Sn("extendForward"),isExtendLineBackward:Sn("extendLineBackward"),isExtendLineForward:Sn("extendLineForward"),isItalic:Sn("italic"),isMoveLineBackward:Sn("moveLineBackward"),isMoveLineForward:Sn("moveLineForward"),isCtrlLeft:Sn("ctrlLeft"),isCtrlRight:Sn("ctrlRight"),isRedo:Sn("redo"),isShiftEnter:Sn("shiftEnter"),isEnter:Sn("enter"),isTransposeCharacter:Sn("transposeCharacter"),isUndo:Sn("undo"),isSpace:Sn("space"),isSelect:Sn("select"),isTab:Sn("tab"),isShiftTab:Sn("shiftTab"),isBackspace:Sn("backspace"),isCmdEnter:Sn("cmdEnter"),isCmd:Sn("cmd"),isEscape:Sn("escape"),isKekceburek:Sn("kekCeburek")},Pn=(e,t)=>!!((e,t)=>{const{selection:n}=e;if(!n)return!1;const[r]=Array.from(b.nodes(e,{at:b.unhangRange(e,n),match:e=>!b.isEditor(e)&&O.isElement(e)&&e.type===t}));return r})(e,t),An=(e,t,n="lowest")=>{var r;const o=Array.from(b.nodes(e,{match:t=>b.isEditor(e)&&O.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 Cn(e,t){var n,r;if(x.isText(e))return function(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,(e=>t[e]))}(e.text);const o=e.children.map((e=>Cn(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 Tn(e,t){return e.map((e=>Cn(e,t))).join("")}const Ln={outline:"none"},Mn={hotkeys:Dn,defaultNode:ft(Ge())},Bn=({editor:r,placeholder:o,marks:i,readOnly:s,plugins:d,className:f,PLUGINS_MAP:h})=>{a((()=>{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 g=c(null),[{disableWhileDrag:y},{changeHoveredNode:m}]=yt(),x=xt(),{ActionMenu:E,Toolbar:k}=x||{},N=y||s,S=l((()=>e=>{var o;const i=h[e.element.type],a=function(e){return"function"==typeof e.renderer?e.renderer:e.renderer.editor}(i)(r,i);return i?t(En,Object.assign({element:e.element,attributes:e.attributes,nodeType:e.element.nodeType,render:a,HTMLAttributes:null===(o=i.options)||void 0===o?void 0:o.HTMLAttributes},{children:e.children})):t(n,{})}),[d,r]),D=l((()=>e=>{const t=[],[n,o]=e;return d.forEach((o=>{const i=o.decorator;"function"==typeof i&&O.isElement(n)&&n.type===o.type&&t.push(...i(r)(e))})),r.selection&&!b.isEditor(n)&&""===b.string(r,[o[0]])&&j.includes(r.selection,o)&&j.isCollapsed(r.selection)&&t.push(Object.assign(Object.assign({},r.selection),{withPlaceholder:!0})),t}),[d,r]),P=l((()=>e=>{var n;const a=Object.assign({},e);let s;d.forEach((e=>{if(e.leaf){const t=e.leaf(r)(a);t&&(a.children=t)}})),null==i||i.forEach((e=>{a.leaf[e.type]&&(a.children=e.render(a))}));const l=null===(n=a.children.props)||void 0===n?void 0:n.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)}(l)){const e=h[null==l?void 0:l.type];s=null===(null==e?void 0:e.placeholder)?null:(null==e?void 0:e.placeholder)||o}return t(ln,Object.assign({},a,{placeholder:s}))}),[d,r]),A=l((()=>{const e=d.map((e=>Object.keys(e.events||{}))).flat().filter(((e,t,n)=>n.indexOf(e)===t)),t={};return e.forEach((e=>{t[e]=function(t){d.forEach((n=>{var o;if(null===(o=n.events)||void 0===o?void 0:o[e]){n.events[e](r,Mn)(t)}}))}})),t}),[d,r]),C=u((e=>{b.withoutNormalizing(r,(()=>{var t;if(!r.selection)return;const n=ft(Ge());null==i||i.forEach((t=>{t.hotkey&&Zt(t.hotkey)(e)&&(e.preventDefault(),pt(r,t.type,!1))})),null===(t=A.onKeyDown)||void 0===t||t.call(A,e);const o=b.above(r,{match:e=>!b.isEditor(e),mode:"lowest"});if(Dn.isEnter(e)){if(e.isDefaultPrevented())return;e.preventDefault();const t=Object.keys(b.marks(r)||{});t.length>0&&t.forEach((e=>b.removeMark(r,e)));const i=w.parent(r.selection.anchor.path),a=b.string(r,i),s=o&&o[0].type!==n.type;if(s&&0===a.length)return void _.setNodes(r,n,{at:i});if(b.isStart(r,r.selection.anchor,r.selection.anchor.path)&&s){const[e]=o;return _.setNodes(r,n,{at:i}),_.delete(r,{unit:"block"}),_.insertNodes(r,Ue(e),{at:w.next(i)}),void _.select(r,{path:[w.next(r.selection.anchor.path)[0]+1,0],offset:0})}return _.splitNodes(r,{always:!0}),_.setNodes(r,n),void m(n)}if(Dn.isShiftEnter(e)){if(e.isDefaultPrevented())return;e.preventDefault(),r.insertText("\n")}if(Dn.isSelect(e)){if(e.isDefaultPrevented())return;e.preventDefault();const t=b.above(r,{at:r.selection.anchor.path,match:e=>!b.isEditor(e)&&O.isElement(e)});if(!t)return;const n=b.string(r,t[1]);return j.isExpanded(r.selection)||0===n.length?void _.select(r,[]):void _.select(r,t[1])}}))}),[]);return e("div",Object.assign({id:"yoopta-editor",className:f,ref:g,onMouseDown:e=>{s||(e.preventDefault(),e.currentTarget===e.target&&r.selection&&b.withoutNormalizing(r,(()=>{const e=[r.children.length-1,0],t=An(r,e,"highest"),n=b.string(r,e),o={anchor:{path:e,offset:0},focus:{path:e,offset:0}};if("paragraph"===t.type&&0===n.length)return _.select(r,{path:o.anchor.path,offset:0}),m(t),p.focus(r);const i=ft(Ge());m(i),_.insertNodes(r,i,{at:[r.children.length],select:!0}),p.focus(r)})))}},{children:[!!E&&t(E,{}),!!k&&t(k,{}),t(v,Object.assign({id:"yoopta-contenteditable",renderLeaf:P,renderElement:S,readOnly:N,decorate:D,onCopy:e=>{if(!r.selection)return;const t=Tn(b.fragment(r,r.selection),r.plugins);return e.clipboardData.setData("text/html",t),e.clipboardData},autoFocus:!0,spellCheck:!0},A,{onKeyDown:C,onMouseDown:e=>{var t;null===(t=A.onMouseDown)||void 0===t||t.call(A,e),(e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()})(e)},style:Ln}))]}))};function Fn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var zn=new WeakMap,Hn=new WeakMap;class Rn{}class In extends Rn{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 Vn extends Rn{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 Wn=e=>Hn.get(e);function Un(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 Zn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Un(Object(n),!0).forEach((function(t){Fn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Un(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var $n=new WeakSet,qn=e=>{var t=[],n=e=>{if(null!=e){var r=t[t.length-1];if("string"==typeof e){var o={text:e};$n.add(o),e=o}if(x.isText(e)){var i=e;x.isText(r)&&$n.has(r)&&$n.has(i)&&x.equals(r,i,{loose:!0})?r.text+=i.text:t.push(i)}else if(O.isElement(e))t.push(e);else{if(!(e instanceof Rn))throw new Error("Unexpected hyperscript child object: ".concat(e));var a=t[t.length-1];x.isText(a)||(n(""),a=t[t.length-1]),e instanceof In?((e,t)=>{var n=e.text.length;zn.set(e,[n,t])})(a,e):e instanceof Vn&&((e,t)=>{var n=e.text.length;Hn.set(e,[n,t])})(a,e)}}};for(var r of e.flat(1/0))n(r);return t};function Kn(e,t,n){return Zn(Zn({},t),{},{children:qn(n)})}function Gn(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 Jn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Gn(Object(n),!0).forEach((function(t){Fn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Gn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Xn,Qn={anchor:function(e,t,n){return new In(t)},cursor:function(e,t,n){return[new In(t),new Vn(t)]},editor:(Xn=N,(e,t,n)=>{var r,o=[];for(var i of n)j.isRange(i)?r=i:o.push(i);var a,s=qn(o),l={},c=Xn();for(var[d,u]of(Object.assign(c,t),c.children=s,k.texts(c))){var f=(a=d,zn.get(a)),p=Wn(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:j.isRange(l)&&(c.selection=l),c}),element:Kn,focus:function(e,t,n){return new Vn(t)},fragment:function(e,t,n){return qn(n)},selection:function(e,t,n){var r=n.find((e=>e instanceof In)),o=n.find((e=>e instanceof Vn));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 Zn({anchor:{offset:r.offset,path:r.path},focus:{offset:o.offset,path:o.path}},t)},text:function(e,t,n){var r=qn(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:""}),!x.isText(o))throw new Error("\n The <text> hyperscript tag can only contain text content as children.");return $n.delete(o),Object.assign(o,t),o}},Yn=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={}),Kt(n)||(o=[n].concat(o),n={}),a(t,n,o=o.filter((e=>Boolean(e))).flat())},er=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)=>Kn(0,Jn(Jn({},r),t),n)};for(var r in e)n(r);return t},tr=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{elements:t={}}=e,n=er(t),r=Jn(Jn(Jn({},Qn),n),e.creators);return Yn(r)}();const nr={DEL:()=>({strikethrough:!0}),EM:()=>({italic:!0}),I:()=>({italic:!0}),S:()=>({strikethrough:!0}),STRONG:()=>({bold:!0}),U:()=>({underline:!0})},rr=(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=>rr(e,t))).flat();if(0===l.length&&(l=[{text:""}]),"BODY"===e.nodeName)return tr("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 tr("element",t,l)}}if(x.isTextList(l))return tr("element",t.P.defineElement(),l);if(nr[a]){const t=nr[a](e);return l.map((e=>x.isText(e)?tr("text",t,e):e))}return l};function or(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 rr(r.body,n)}catch(e){return console.error(e),null}}const ir=({key:e,value:n,plugins:r,marks:o,readOnly:s,onChange:c,placeholder:d,autoFocus:f=!0,offline:h,className:g,tools:v})=>{const S=function(e){return"string"==typeof e?e:"yoopta-content"}(h),[D,P]=i((()=>function(e,t,n){const r=[{id:Ge(),type:"paragraph",children:[{text:""}]}],o=rn(n)?n:r;if(!t)return localStorage.removeItem(e),o;try{const t=JSON.parse(localStorage.getItem(e)||"[]");return rn(t)?t:o}catch(t){return localStorage.removeItem(e),r}}(S,h,n))),A=u((e=>{if(c(e),P(e),!h)return;if(M.operations.some((e=>"set_selection"!==e.type)))try{const t=JSON.stringify(e);localStorage.setItem(S,t)}catch(e){}}),[h]),C=l((()=>{const e=be(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:L}=C,M=l((()=>{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=or(r,e.plugins);return console.log("fragment",t),void _.insertFragment(e,t)}t(n)},e})((e=>{const{deleteFragment:t}=e;return e.deleteFragment=()=>{const{selection:n}=e;if(!n)return;const[,r]=b.first(e,[0]),[,o]=b.last(e,[e.children.length-1]),i=b.range(e,r,o);if(j.equals(n,i))return _.removeNodes(e,{mode:"highest",hanging:!0}),void _.select(e,[0]);t()},e})((e=>{const{normalizeNode:t}=e;return e.normalizeNode=n=>{const[r]=n;if(b.isEditor(r)&&0===e.children.length){const t=ft(Ge());_.insertNodes(e,t,{at:[0]})}else t(n)},e})((e=>{const{insertBreak:t,deleteBackward:n}=e;return e.insertBreak=()=>{if(!e.selection||!j.isCollapsed(e.selection))return t();const n=w.parent(e.selection.anchor.path),r=k.get(e,n);O.isElement(r)&&b.isVoid(e,r)?b.insertNode(e,{id:Ge(),type:"paragraph",children:[{text:""}],nodeType:"block"}):t()},e.deleteBackward=t=>{if(!e.selection||!j.isCollapsed(e.selection)||0!==e.selection.anchor.offset)return n(t);const r=w.parent(e.selection.anchor.path),o=k.get(e,r);if(0===k.string(o).length&&w.hasPrevious(r)){const t=w.previous(r),n=k.get(e,t);if(O.isElement(n)&&b.isVoid(e,n))return _.removeNodes(e),_.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];Qt.withoutSaving(t,(()=>{b.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];Qt.withoutSaving(t,(()=>{b.withoutNormalizing(t,(()=>{var e=r.map(E.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=tn(e,s),c=Qt.isSaving(t),d=Qt.isMerging(t);if(null==c&&(c=en(e)),c){if(null==d&&(d=null!=a&&(0!==r.length||Yt(e,s)||l)),a&&d)l&&a.pop(),a.push(e);else{var u=[e];i.push(u)}for(;i.length>100;)i.shift();nn(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&&j.isCollapsed(i)){const{anchor:a}=i,s=b.above(e,{match:t=>O.isElement(t)&&b.isBlock(e,t),mode:"lowest"});if(!s)return;const[,l]=s,c=b.parent(e,l),[d]=c;if(O.isElement(d)&&!x.isText(d.children[0]))return t(n);const u=s?l:[],f={anchor:a,focus:b.start(e,u)},p=b.string(e,f),h=null===(r=e.shortcuts)||void 0===r?void 0:r[p];if(h)return _.select(e,f),_.delete(e),void(null===(o=h.createElement)||void 0===o||o.call(h,e))}t(n)},e})(y(N())))))));e.plugins=L;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 a((()=>{if(f)try{const[,e]=b.first(M,[0]);_.select(M,{anchor:{path:e,offset:0},focus:{path:e,offset:0}}),p.focus(M)}catch(e){}}),[f,M]),t(m,Object.assign({editor:M,initialValue:D,onChange:A},{children:t(vt,{children:t(bt,Object.assign({plugins:T,marks:o,tools:v},{children:t(Bn,{editor:M,readOnly:s,placeholder:d,plugins:T,marks:o,PLUGINS_MAP:L,className:g})}))})}),e)},ar=e=>t($t,{children:t(ir,Object.assign({},e,{value:e.value,onChange:e.onChange}))});function sr({type:e,hotkey:n,className:r,as:o}){return Object.freeze({type:e,hotkey:n,render:n=>t(o||"span",Object.assign({},n.attributes,{className:Oe(r,`yoopta-leaf-${e}`)},{children:n.children}))})}function lr(e){const{element:t,HTMLAttributes:n,className:r}=e;return`yoopta-${t.type} ${(null==n?void 0:n.className)||""} ${r}`}const cr={ElementOptions:At,Overlay:De};export{Dn as HOTKEYS,cr as UI_HELPERS,ye as YooptaPlugin,sr as createYooptaMark,me as createYooptaPlugin,Oe as cx,Ue as deepClone,ar as default,st as disableBodyScroll,lt as enableBodyScroll,Ge as generateId,An as getElementByPath,lr as getElementClassname,Ut as isCodeHotkey,Pn as isElementActive,Wt as isHotkey,Zt as isKeyHotkey,rn as isValidYooptaNodes,be as mergePlugins,Ot as useElements,_t as useMarks,yt as useNodeElementSettings,xt as useTools,wt as useYoopta};
|
package/dist/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { BaseEditor, BaseElement } from 'slate';
|
|
|
2
2
|
import { ReactEditor, RenderElementProps as ElementProps } from 'slate-react';
|
|
3
3
|
import { HistoryEditor } from 'slate-history';
|
|
4
4
|
import { YooptaPluginType, YooptaRenderHTMLAttributes } from './utils/plugins';
|
|
5
|
-
import { CSSProperties } from 'react';
|
|
5
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
6
6
|
export type EmptyText = {
|
|
7
7
|
text: string;
|
|
8
8
|
};
|
|
@@ -34,3 +34,20 @@ export interface YooEditor extends BaseEditor, ReactEditor, HistoryEditor {
|
|
|
34
34
|
shortcuts: Record<string, YooptaPluginType>;
|
|
35
35
|
plugins: Record<YooptaBaseElement<string>['type'], YooptaPluginType<any, YooptaBaseElement<string>>>;
|
|
36
36
|
}
|
|
37
|
+
export type YooptaNodeElementSettings = {
|
|
38
|
+
options?: {
|
|
39
|
+
handlers?: {
|
|
40
|
+
onCopy?: () => void;
|
|
41
|
+
onDelete?: () => void;
|
|
42
|
+
onDuplicate?: () => void;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
drag?: boolean;
|
|
46
|
+
plus?: boolean;
|
|
47
|
+
};
|
|
48
|
+
export type YooptaTools = {
|
|
49
|
+
ActionMenu?: ReactNode;
|
|
50
|
+
Toolbar?: ReactNode;
|
|
51
|
+
ChatGPT?: ReactNode;
|
|
52
|
+
[x: string]: ReactNode;
|
|
53
|
+
};
|