@yoopta/editor 1.9.5-rc → 1.9.7-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.
@@ -3,19 +3,30 @@ import { YooptaBaseElement } from '../../types';
3
3
  import { YooptaPlugin, YooptaPluginType } from '../../utils/plugins';
4
4
  import { YooptaMark } from '../../utils/marks';
5
5
  export type HoveredElement = YooptaBaseElement<string> | null;
6
- export type YooptaContextValues = {
6
+ export type YooptaContextReturnValues = {
7
7
  marks: MarksMap;
8
- plugins: PluginsMap;
8
+ elements: ElementsMap;
9
9
  };
10
10
  export type YooptaContextHandlers = {};
11
- export type YooptaContextType = YooptaContextValues;
12
- type NodeSettingsProps = {
11
+ export type YooptaContextType = YooptaContextReturnValues;
12
+ type YooptaContextProps = {
13
13
  children: ReactNode;
14
14
  plugins: YooptaPlugin<any, any>[];
15
15
  marks?: YooptaMark[];
16
+ tools: any;
16
17
  };
17
- type PluginsMap = Record<string, Pick<YooptaPluginType, 'type' | 'createElement' | 'defineElement'>>;
18
- type MarksMap = {
18
+ export type ToggleOptions = {
19
+ shouldDeleteText: boolean;
20
+ };
21
+ export type ElementsMap = {
22
+ [x: string]: {
23
+ type: YooptaPluginType['type'];
24
+ create: YooptaPluginType['createElement'];
25
+ define: YooptaPluginType['defineElement'];
26
+ toggle: (options?: ToggleOptions) => void;
27
+ };
28
+ };
29
+ export type MarksMap = {
19
30
  [x: string]: {
20
31
  toggle: (options?: {
21
32
  only: boolean;
@@ -23,6 +34,8 @@ type MarksMap = {
23
34
  isActive: boolean;
24
35
  };
25
36
  };
26
- declare const YooptaContextProvider: ({ children, plugins: pluginList, marks: markList }: NodeSettingsProps) => JSX.Element;
27
- declare const useYoopta: () => YooptaContextValues;
28
- export { YooptaContextProvider, useYoopta };
37
+ declare const YooptaContextProvider: ({ children, plugins: pluginList, marks: markList }: YooptaContextProps) => JSX.Element;
38
+ declare const useYoopta: () => YooptaContextReturnValues;
39
+ declare const useMarks: () => MarksMap;
40
+ declare const useElements: () => ElementsMap;
41
+ export { YooptaContextProvider, useYoopta, useMarks, useElements };
package/dist/index.d.ts CHANGED
@@ -8,7 +8,8 @@ import { YooptaEditor } from './YooptaEditor';
8
8
  export { isValidYooptaNodes } from './utils/validate';
9
9
  export { generateId } from './utils/generateId';
10
10
  export { HOTKEYS } from './utils/hotkeys';
11
- export { useYoopta } from './contexts/YooptaContext/YooptaContext';
11
+ export { useYoopta, useMarks, useElements } from './contexts/YooptaContext/YooptaContext';
12
+ export type { ElementsMap, MarksMap } from './contexts/YooptaContext/YooptaContext';
12
13
  export { deepClone } from './utils/deepClone';
13
14
  export { createYooptaMark } from './utils/marks';
14
15
  export { isElementActive, getElementByPath } from './utils/nodes';
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import*as n from"react";import r,{useState as o,useEffect as i,useContext as a,useMemo as s,memo as l,useRef as c,useCallback as d}from"react";import{createPortal as u}from"react-dom";import{ReactEditor as f,useSlate as p,useSelected as h,Editable as g,withReact as v,Slate as y}from"slate-react";import{Editor as m,Path as b,Transforms as w,Element as _,Operation as x,Text as O,Range as j,Node as E,createEditor as k}from"slate";import{randomFillSync as N}from"crypto";function S(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 D(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)}var P="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},C=200,A="__lodash_hash_undefined__",T="[object Function]",L="[object GeneratorFunction]",B=/^\[object .+?Constructor\]$/,M="object"==typeof P&&P&&P.Object===Object&&P,F="object"==typeof self&&self&&self.Object===Object&&self,R=M||F||Function("return this")();function H(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,z,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 z(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 V,Z=Array.prototype,$=Function.prototype,q=Object.prototype,K=R["__core-js_shared__"],G=(V=/[^.]+$/.exec(K&&K.keys&&K.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",J=$.toString,X=q.hasOwnProperty,Q=q.toString,Y=RegExp("^"+J.call(X).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ee=Z.splice,te=fe(R,"Map"),ne=fe(R,"Set"),re=fe(Object,"create");function oe(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 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.__data__=new ae;++t<n;)this.add(e[t])}function le(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 ce(e){if(!pe(e)||(t=e,G&&G in t))return!1;var t,n=function(e){var t=pe(e)?Q.call(e):"";return t==T||t==L}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?Y:B;return n.test(function(e){if(null!=e){try{return J.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}oe.prototype.clear=function(){this.__data__=re?re(null):{}},oe.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},oe.prototype.get=function(e){var t=this.__data__;if(re){var n=t[e];return n===A?void 0:n}return X.call(t,e)?t[e]:void 0},oe.prototype.has=function(e){var t=this.__data__;return re?void 0!==t[e]:X.call(t,e)},oe.prototype.set=function(e,t){return this.__data__[e]=re&&void 0===t?A:t,this},ie.prototype.clear=function(){this.__data__=[]},ie.prototype.delete=function(e){var t=this.__data__,n=le(t,e);return!(n<0)&&(n==t.length-1?t.pop():ee.call(t,n,1),!0)},ie.prototype.get=function(e){var t=this.__data__,n=le(t,e);return n<0?void 0:t[n][1]},ie.prototype.has=function(e){return le(this.__data__,e)>-1},ie.prototype.set=function(e,t){var n=this.__data__,r=le(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},ae.prototype.clear=function(){this.__data__={hash:new oe,map:new(te||ie),string:new oe}},ae.prototype.delete=function(e){return ue(this,e).delete(e)},ae.prototype.get=function(e){return ue(this,e).get(e)},ae.prototype.has=function(e){return ue(this,e).has(e)},ae.prototype.set=function(e,t){return ue(this,e).set(e,t),this},se.prototype.add=se.prototype.push=function(e){return this.__data__.set(e,A),this},se.prototype.has=function(e){return this.__data__.has(e)};var de=ne&&1/U(new ne([,-0]))[1]==1/0?function(e){return new ne(e)}:function(){};function ue(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 ce(n)?n:void 0}function pe(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}var he,ge=function(e,t){return e&&e.length?function(e,t,n){var r=-1,o=H,i=e.length,a=!0,s=[],l=s;if(n)a=!1,o=I;else if(i>=C){var c=t?null:de(e);if(c)return U(c);a=!1,o=W,l=new se}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 ve{constructor(e){he.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,he,Object.freeze(Object.assign({},e)),"f")}extend(e){const{type:t=D(this,he,"f").type,renderer:n=D(this,he,"f").renderer,placeholder:r=D(this,he,"f").placeholder,shortcut:o=D(this,he,"f").shortcut,exports:i=D(this,he,"f").exports,events:a=D(this,he,"f").events,options:s=D(this,he,"f").options}=e,l=Object.freeze(Object.assign(Object.assign({},D(this,he,"f")),{type:t,renderer:n,placeholder:r,shortcut:o,exports:i,events:a,options:s}));return new ve(l)}get getPlugin(){return D(this,he,"f")}}function ye(e){return new ve(e)}function me(e){const t=e.map((e=>{const t=e.getPlugin,{childPlugin:n}=t,r=S(t,["childPlugin"]);return n?[r,Object.assign(Object.assign({},n.getPlugin),{hasParent:!0})]:r})).flat();return ge(t,((e,t)=>e.type===t.type))}he=new WeakMap;var be,we={};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import*as n from"react";import r,{useState as o,useEffect as i,useContext as a,useMemo as s,memo as l,useRef as c,useCallback as d}from"react";import{createPortal as u}from"react-dom";import{ReactEditor as f,useSlate as p,useSelected as h,Editable as v,withReact as g,Slate as y}from"slate-react";import{Editor as m,Path as b,Transforms as w,Element as _,Operation as x,Text as O,Range as j,Node as E,createEditor as k}from"slate";import{randomFillSync as N}from"crypto";function S(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 D(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)}var P="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},C=200,A="__lodash_hash_undefined__",T="[object Function]",L="[object GeneratorFunction]",B=/^\[object .+?Constructor\]$/,M="object"==typeof P&&P&&P.Object===Object&&P,F="object"==typeof self&&self&&self.Object===Object&&self,z=M||F||Function("return this")();function H(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,R,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 R(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 V,Z=Array.prototype,$=Function.prototype,q=Object.prototype,K=z["__core-js_shared__"],G=(V=/[^.]+$/.exec(K&&K.keys&&K.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",J=$.toString,X=q.hasOwnProperty,Q=q.toString,Y=RegExp("^"+J.call(X).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ee=Z.splice,te=fe(z,"Map"),ne=fe(z,"Set"),re=fe(Object,"create");function oe(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 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.__data__=new ae;++t<n;)this.add(e[t])}function le(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 ce(e){if(!pe(e)||(t=e,G&&G in t))return!1;var t,n=function(e){var t=pe(e)?Q.call(e):"";return t==T||t==L}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?Y:B;return n.test(function(e){if(null!=e){try{return J.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}oe.prototype.clear=function(){this.__data__=re?re(null):{}},oe.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},oe.prototype.get=function(e){var t=this.__data__;if(re){var n=t[e];return n===A?void 0:n}return X.call(t,e)?t[e]:void 0},oe.prototype.has=function(e){var t=this.__data__;return re?void 0!==t[e]:X.call(t,e)},oe.prototype.set=function(e,t){return this.__data__[e]=re&&void 0===t?A:t,this},ie.prototype.clear=function(){this.__data__=[]},ie.prototype.delete=function(e){var t=this.__data__,n=le(t,e);return!(n<0)&&(n==t.length-1?t.pop():ee.call(t,n,1),!0)},ie.prototype.get=function(e){var t=this.__data__,n=le(t,e);return n<0?void 0:t[n][1]},ie.prototype.has=function(e){return le(this.__data__,e)>-1},ie.prototype.set=function(e,t){var n=this.__data__,r=le(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},ae.prototype.clear=function(){this.__data__={hash:new oe,map:new(te||ie),string:new oe}},ae.prototype.delete=function(e){return ue(this,e).delete(e)},ae.prototype.get=function(e){return ue(this,e).get(e)},ae.prototype.has=function(e){return ue(this,e).has(e)},ae.prototype.set=function(e,t){return ue(this,e).set(e,t),this},se.prototype.add=se.prototype.push=function(e){return this.__data__.set(e,A),this},se.prototype.has=function(e){return this.__data__.has(e)};var de=ne&&1/U(new ne([,-0]))[1]==1/0?function(e){return new ne(e)}:function(){};function ue(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 ce(n)?n:void 0}function pe(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}var he,ve=function(e,t){return e&&e.length?function(e,t,n){var r=-1,o=H,i=e.length,a=!0,s=[],l=s;if(n)a=!1,o=I;else if(i>=C){var c=t?null:de(e);if(c)return U(c);a=!1,o=W,l=new se}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 ge{constructor(e){he.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,he,Object.freeze(Object.assign({},e)),"f")}extend(e){const{type:t=D(this,he,"f").type,renderer:n=D(this,he,"f").renderer,placeholder:r=D(this,he,"f").placeholder,shortcut:o=D(this,he,"f").shortcut,exports:i=D(this,he,"f").exports,events:a=D(this,he,"f").events,options:s=D(this,he,"f").options}=e,l=Object.freeze(Object.assign(Object.assign({},D(this,he,"f")),{type:t,renderer:n,placeholder:r,shortcut:o,exports:i,events:a,options:s}));return new ge(l)}get getPlugin(){return D(this,he,"f")}}function ye(e){return new ge(e)}function me(e){const t=e.map((e=>{const t=e.getPlugin,{childPlugin:n}=t,r=S(t,["childPlugin"]);return n?[r,Object.assign(Object.assign({},n.getPlugin),{hasParent:!0})]:r})).flat();return ve(t,((e,t)=>e.type===t.type))}he=new WeakMap;var be,we={};
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 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 Oe="QEROK9NJ",je="ZLDKsGEc",Ee="_0wBAdXIb",ke="P40m4iJS",Ne="_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 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:Oe},{children:[t("div",{className:je}),e("div",Object.assign({className:Ee},{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 Ce,Ae=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,Be=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),Ce||(Ce=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 Me(){return Me=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},Me.apply(this,arguments)}var Fe=function(e){return n.createElement("svg",Me({viewBox:"0 0 16 16",className:"copy_svg__link",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Le||(Le=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"})))},Re={};!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]",x="[object Float64Array]",O="[object Int8Array]",j="[object Int16Array]",E="[object Int32Array]",k="[object Uint8Array]",N="[object Uint8ClampedArray]",S="[object Uint16Array]",D="[object Uint32Array]",C=/\w*$/,A=/^\[object .+?Constructor\]$/,T=/^(?:0|[1-9]\d*)$/,L={};L[i]=L["[object Array]"]=L[b]=L[w]=L[a]=L[s]=L[_]=L[x]=L[O]=L[j]=L[E]=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 B="object"==typeof P&&P&&P.Object===Object&&P,M="object"==typeof self&&self&&self.Object===Object&&self,F=B||M||Function("return this")(),R=t&&!t.nodeType&&t,H=R&&e&&!e.nodeType&&e,I=H&&H.exports===R;function z(e,t){return e.set(t[0],t[1]),e}function W(e,t){return e.add(t),e}function U(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 V(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=I?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=Re(F,"DataView"),he=Re(F,"Map"),ge=Re(F,"Promise"),ve=Re(F,"Set"),ye=Re(F,"WeakMap"),me=Re(Object,"create"),be=Ue(pe),we=Ue(he),_e=Ue(ge),xe=Ue(ve),Oe=Ue(ye),je=oe?oe.prototype:void 0,Ee=je?je.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||ze(a,r))||n.push(a);return n}function Ce(e,t,n){var r=e[t];ee.call(e,t)&&Ve(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function Ae(e,t){for(var n=e.length;n--;)if(Ve(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 A=Ze(e);if(A){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=Ie(e),B=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||B&&!p){if(V(e))return p?e:{};if(P=function(e){return"function"!=typeof e.constructor||We(e)?{}:(t=ae(e),Ge(t)?se(t):{});var t}(B?{}:e),!t)return function(e,t){return Me(e,He(e),t)}(e,function(e,t){return e&&Me(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 Be(e);case a:case s:return new o(+e);case w:return function(e,t){var n=t?Be(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,r);case _:case x:case O:case j:case E:case k:case N:case S:case D:return function(e,t){var n=t?Be(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 U(r,z,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,C.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 U(r,W,new e.constructor)}(e,r,n);case y:return i=e,Ee?Object(Ee.call(i)):{}}var i}(e,T,Te,t)}}m||(m=new De);var M=m.get(e);if(M)return M;if(m.set(e,P),!A)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]),Ce(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)||V(e)?ne:A).test(Ue(e));var t}function Be(e){var t=new e.constructor(e.byteLength);return new ie(t).set(new ie(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;Ce(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 Re(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=Ae(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=Ae(t,e);return n<0?void 0:t[n][1]},Ne.prototype.has=function(e){return Ae(this.__data__,e)>-1},Ne.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},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[]},Ie=function(e){return te.call(e)};function ze(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||T.test(e))&&e>-1&&e%1==0&&e<t}function We(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||J)}function Ue(e){if(null!=e){try{return Y.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ve(e,t){return e===t||e!=e&&t!=t}(pe&&Ie(new pe(new ArrayBuffer(1)))!=w||he&&Ie(new he)!=d||ge&&Ie(ge.resolve())!=p||ve&&Ie(new ve)!=g||ye&&Ie(new ye)!=m)&&(Ie=function(e){var t=te.call(e),n=t==f?e.constructor:void 0,r=n?Ue(n):void 0;if(r)switch(r){case be:return w;case we:return d;case _e:return p;case xe:return g;case Oe: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(!We(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 Re},set exports(e){Re=e}},Re);var He=Re;function Ie(e){return"function"==typeof window.structuredClone?window.structuredClone(e):He(e)}const ze={from:{path:null,element:null,parent:null},to:{path:null,element:null,parent:null}};let We,Ue,Ve=(e=21)=>{var t;t=e-=0,!We||We.length<t?(We=Buffer.allocUnsafe(128*t),N(We),Ue=0):Ue+t>We.length&&(N(We),Ue=0),Ue+=t;let n="";for(let t=Ue-e;t<Ue;t++)n+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&We[t]];return n};const Ze=()=>Ve();var $e=!1;if("undefined"!=typeof window){var qe={get passive(){$e=!0}};window.addEventListener("testPassive",null,qe),window.removeEventListener("testPassive",null,qe)}var Ke="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),Ge=[],Je=!1,Xe=-1,Qe=void 0,Ye=void 0,et=void 0,tt=function(e){return Ge.some((function(t){return!(!t.options.allowTouchMove||!t.options.allowTouchMove(e))}))},nt=function(e){var t=e||window.event;return!!tt(t.target)||(t.touches.length>1||(t.preventDefault&&t.preventDefault(),!1))},rt=function(e,t){if(e){if(!Ge.some((function(t){return t.targetElement===e}))){var n={targetElement:e,options:t||{}};Ge=[].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)}(Ge),[n]),Ke?window.requestAnimationFrame((function(){if(void 0===Ye){Ye={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===et){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);et=document.body.style.paddingRight,document.body.style.paddingRight=r+n+"px"}}void 0===Qe&&(Qe=document.body.style.overflow,document.body.style.overflow="hidden")}(t),Ke&&(e.ontouchstart=function(e){1===e.targetTouches.length&&(Xe=e.targetTouches[0].clientY)},e.ontouchmove=function(t){1===t.targetTouches.length&&function(e,t){var n=e.targetTouches[0].clientY-Xe;!tt(e.target)&&(t&&0===t.scrollTop&&n>0||function(e){return!!e&&e.scrollHeight-e.scrollTop<=e.clientHeight}(t)&&n<0?nt(e):e.stopPropagation())}(t,e)},Je||(document.addEventListener("touchmove",nt,$e?{passive:!1}:void 0),Je=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},ot=function(e){e?(Ge=Ge.filter((function(t){return t.targetElement!==e})),Ke&&(e.ontouchstart=null,e.ontouchmove=null,Je&&0===Ge.length&&(document.removeEventListener("touchmove",nt,$e?{passive:!1}:void 0),Je=!1)),Ke?function(){if(void 0!==Ye){var e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);document.body.style.position=Ye.position,document.body.style.top=Ye.top,document.body.style.left=Ye.left,window.scrollTo(t,e),Ye=void 0}}():(void 0!==et&&(document.body.style.paddingRight=et,et=void 0),void 0!==Qe&&(document.body.style.overflow=Qe,Qe=void 0))):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")},it=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()}},at={"text/plain":"Text","text/html":"Url",default:"Text"},st="Copy to clipboard: #{key}, Enter";var lt=function(e,t){var n,r,o,i,a,s,l=!1;t||(t={}),n=t.debug||!1;try{if(o=it(),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=at[t.format]||at.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:st),window.prompt(r,e)}}finally{a&&("function"==typeof a.removeRange?a.removeRange(i):a.removeAllRanges()),s&&document.body.removeChild(s),o()}return l};const ct=e=>({id:e,type:"paragraph",nodeType:"block",children:[{text:""}]});function dt(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 ut={hoveredElement:null,isElementOptionsOpen:!1,nodeSettingsPos:null,dndState:ze,disableWhileDrag:!1,DRAG_MAP:new Map},ft=r.createContext([ut,{openNodeSettings:(e,t)=>{},closeNodeSettings:()=>{},hoverIn:(e,t)=>{},triggerPlusButton:e=>{},deleteNode:()=>{},duplicateNode:()=>{},copyLinkNode:()=>{},onDrop:e=>{},onDragEnd:e=>{},onDragEnter:e=>{},onDragStart:e=>{},changeHoveredNode:e=>{}}]),pt=({children:e})=>{const n=p(),[r,i]=(e=>{const[t,n]=o(!1),[r,i]=o(ze),[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=Ie(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(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),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(!1),g=Object.assign({hoveredElement:c,isElementOptionsOpen:u,nodeSettingsPos:a},r),v=s((()=>Object.assign({hoverIn:(e,t)=>{var n;if(u)return e.preventDefault();(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.skipSettings)||d(t)},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=ct(Ze());w.insertNodes(n,o,{at:r,select:!0}),d(o)}))},openNodeSettings:(e,t)=>{if(rt(document.body,{reserveScrollBarGap:!0}),h(!0),e.current){const t=e.current.getBoundingClientRect();l({left:t.left+t.width+10,top:t.top})}},closeNodeSettings:()=>{ot(document.body),h(!1),l(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 v.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),v.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=Ie(c);r.id=Ze(),w.insertNodes(n,r,{at:t,match:e=>_.isElement(e),mode:"highest",select:!0}),f.focus(n),d(null),v.closeNodeSettings()}))},copyLinkNode:()=>{0===window.location.hash.length?lt(`${window.location.href}#${null==c?void 0:c.id}`):lt(`${window.location.href.split("#")[0]}#${null==c?void 0:c.id}`),v.closeNodeSettings()}},i)),[c,u,r,n.children]),y=s((()=>[g,v]),[c,u,r,n.selection,n.children]);return t(ft.Provider,Object.assign({value:y},{children:e}))},ht=()=>a(ft);var gt="IMJgzRnZ",vt="nFfAiJWo",yt="DeARgIyF",mt="kyuzONcU",bt="_95up7F66",wt="_9d0T-cEo";xe(".IMJgzRnZ{align-items:center;background:linear-gradient(90deg,rgba(49,49,47,.99),#262625);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;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:#fff;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:#383835;color:#fff}._95up7F66{align-items:center;color:#fff;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 _t=n=>{var{onClose:r,style:o,element:i,render:a}=n,s=S(n,["onClose","style","element","render"]);const l=p(),[,c]=ht();m.isVoid(l,i);const d=()=>{var e;c.deleteNode(),null===(e=s.onDelete)||void 0===e||e.call(s)},u=()=>{var e;c.duplicateNode(),null===(e=s.onDuplicate)||void 0===e||e.call(s)},f=()=>{var e;c.copyLinkNode(),null===(e=s.onCopy)||void 0===e||e.call(s)};return t(Se,a?Object.assign({onClose:r},{children:t("div",Object.assign({style:o,className:gt},{children:a({handleDelete:d,handleDuplicate:u,handleCopy:f})}))}):Object.assign({onClose:r},{children:t("div",Object.assign({style:o,className:gt},{children:t("div",Object.assign({className:vt},{children:e("div",Object.assign({className:yt},{children:[e("button",Object.assign({type:"button",className:mt,onClick:d},{children:[t("div",Object.assign({className:bt},{children:t(Ae,{})})),t("div",Object.assign({className:wt},{children:"Delete"}))]})),e("button",Object.assign({type:"button",className:mt,onClick:u},{children:[t("div",Object.assign({className:bt},{children:t(Be,{})})),t("div",Object.assign({className:wt},{children:"Duplicate"}))]})),e("button",Object.assign({type:"button",className:mt,onClick:f},{children:[t("div",Object.assign({className:bt},{children:t(Fe,{})})),t("div",Object.assign({className:wt},{children:"Copy link to block"}))]}))]}))}))}))}))};var xt={};Object.defineProperty(xt,"__esModule",{value:!0});for(var Ot="undefined"!=typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),jt={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},Et={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:Ot?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},kt={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},Nt=1;Nt<20;Nt++)kt["f"+Nt]=111+Nt;function St(e,t,n){t&&!("byKey"in t)&&(n=t,t=null),Array.isArray(e)||(e=[e]);var r=e.map((function(e){return Dt(e,t)})),o=function(e){return r.some((function(t){return Pt(t,e)}))};return null==n?o:o(n)}function Dt(e,t){var n=t&&t.byKey,r={},o=(e=e.replace("++","+add")).split("+"),i=o.length;for(var a in jt)r[jt[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=At(f),g=jt[h];if(f.length>1&&!g&&!Et[f]&&!kt[h])throw new TypeError('Unknown modifier: "'+f+'"');1!==i&&g||(n?r.key=h:r.which=Ct(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 Pt(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 Ct(e){return e=At(e),kt[e]||e.toUpperCase().charCodeAt(0)}function At(e){return e=e.toLowerCase(),e=Et[e]||e}xt.default=St;var Tt=xt.isHotkey=St,Lt=xt.isCodeHotkey=function(e,t){return St(e,t)},Bt=xt.isKeyHotkey=function(e,t){return St(e,{byKey:!0},t)};xt.parseHotkey=Dt,xt.compareHotkey=Pt,xt.toKeyCode=Ct,xt.toKeyName=At;const Mt=({children:e,fallback:t=null})=>{const[n,r]=o(!1);return i((()=>r(!0)),[]),n?e:t};
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 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 Oe="QEROK9NJ",je="ZLDKsGEc",Ee="_0wBAdXIb",ke="P40m4iJS",Ne="_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 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:Oe},{children:[t("div",{className:je}),e("div",Object.assign({className:Ee},{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 Ce,Ae=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,Be=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),Ce||(Ce=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 Me(){return Me=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},Me.apply(this,arguments)}var Fe=function(e){return n.createElement("svg",Me({viewBox:"0 0 16 16",className:"copy_svg__link",style:{width:16,height:16,display:"block",fill:"currentColor",flexShrink:0,backfaceVisibility:"hidden"}},e),Le||(Le=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"})))},ze={};!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]",v="[object Set]",g="[object String]",y="[object Symbol]",m="[object WeakMap]",b="[object ArrayBuffer]",w="[object DataView]",_="[object Float32Array]",x="[object Float64Array]",O="[object Int8Array]",j="[object Int16Array]",E="[object Int32Array]",k="[object Uint8Array]",N="[object Uint8ClampedArray]",S="[object Uint16Array]",D="[object Uint32Array]",C=/\w*$/,A=/^\[object .+?Constructor\]$/,T=/^(?:0|[1-9]\d*)$/,L={};L[i]=L["[object Array]"]=L[b]=L[w]=L[a]=L[s]=L[_]=L[x]=L[O]=L[j]=L[E]=L[d]=L[u]=L[f]=L[h]=L[v]=L[g]=L[y]=L[k]=L[N]=L[S]=L[D]=!0,L["[object Error]"]=L[l]=L[m]=!1;var B="object"==typeof P&&P&&P.Object===Object&&P,M="object"==typeof self&&self&&self.Object===Object&&self,F=B||M||Function("return this")(),z=t&&!t.nodeType&&t,H=z&&e&&!e.nodeType&&e,I=H&&H.exports===z;function R(e,t){return e.set(t[0],t[1]),e}function W(e,t){return e.add(t),e}function U(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 V(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=I?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"),ve=ze(F,"Promise"),ge=ze(F,"Set"),ye=ze(F,"WeakMap"),me=ze(Object,"create"),be=Ue(pe),we=Ue(he),_e=Ue(ve),xe=Ue(ge),Oe=Ue(ye),je=oe?oe.prototype:void 0,Ee=je?je.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||Re(a,r))||n.push(a);return n}function Ce(e,t,n){var r=e[t];ee.call(e,t)&&Ve(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function Ae(e,t){for(var n=e.length;n--;)if(Ve(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 A=Ze(e);if(A){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=Ie(e),B=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||B&&!p){if(V(e))return p?e:{};if(P=function(e){return"function"!=typeof e.constructor||We(e)?{}:(t=ae(e),Ge(t)?se(t):{});var t}(B?{}:e),!t)return function(e,t){return Me(e,He(e),t)}(e,function(e,t){return e&&Me(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 Be(e);case a:case s:return new o(+e);case w:return function(e,t){var n=t?Be(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,r);case _:case x:case O:case j:case E:case k:case N:case S:case D:return function(e,t){var n=t?Be(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 U(r,R,new e.constructor)}(e,r,n);case u:case g:return new o(e);case h:return function(e){var t=new e.constructor(e.source,C.exec(e));return t.lastIndex=e.lastIndex,t}(e);case v:return function(e,t,n){var r=t?n(q(e),!0):q(e);return U(r,W,new e.constructor)}(e,r,n);case y:return i=e,Ee?Object(Ee.call(i)):{}}var i}(e,T,Te,t)}}m||(m=new De);var M=m.get(e);if(M)return M;if(m.set(e,P),!A)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]),Ce(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)||V(e)?ne:A).test(Ue(e));var t}function Be(e){var t=new e.constructor(e.byteLength);return new ie(t).set(new ie(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;Ce(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=Ae(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=Ae(t,e);return n<0?void 0:t[n][1]},Ne.prototype.has=function(e){return Ae(this.__data__,e)>-1},Ne.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},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[]},Ie=function(e){return te.call(e)};function Re(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||T.test(e))&&e>-1&&e%1==0&&e<t}function We(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||J)}function Ue(e){if(null!=e){try{return Y.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ve(e,t){return e===t||e!=e&&t!=t}(pe&&Ie(new pe(new ArrayBuffer(1)))!=w||he&&Ie(new he)!=d||ve&&Ie(ve.resolve())!=p||ge&&Ie(new ge)!=v||ye&&Ie(new ye)!=m)&&(Ie=function(e){var t=te.call(e),n=t==f?e.constructor:void 0,r=n?Ue(n):void 0;if(r)switch(r){case be:return w;case we:return d;case _e:return p;case xe:return v;case Oe: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(!We(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 ze},set exports(e){ze=e}},ze);var He=ze;function Ie(e){return"function"==typeof window.structuredClone?window.structuredClone(e):He(e)}const Re={from:{path:null,element:null,parent:null},to:{path:null,element:null,parent:null}};let We,Ue,Ve=(e=21)=>{var t;t=e-=0,!We||We.length<t?(We=Buffer.allocUnsafe(128*t),N(We),Ue=0):Ue+t>We.length&&(N(We),Ue=0),Ue+=t;let n="";for(let t=Ue-e;t<Ue;t++)n+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&We[t]];return n};const Ze=()=>Ve();var $e=!1;if("undefined"!=typeof window){var qe={get passive(){$e=!0}};window.addEventListener("testPassive",null,qe),window.removeEventListener("testPassive",null,qe)}var Ke="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),Ge=[],Je=!1,Xe=-1,Qe=void 0,Ye=void 0,et=void 0,tt=function(e){return Ge.some((function(t){return!(!t.options.allowTouchMove||!t.options.allowTouchMove(e))}))},nt=function(e){var t=e||window.event;return!!tt(t.target)||(t.touches.length>1||(t.preventDefault&&t.preventDefault(),!1))},rt=function(e,t){if(e){if(!Ge.some((function(t){return t.targetElement===e}))){var n={targetElement:e,options:t||{}};Ge=[].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)}(Ge),[n]),Ke?window.requestAnimationFrame((function(){if(void 0===Ye){Ye={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===et){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);et=document.body.style.paddingRight,document.body.style.paddingRight=r+n+"px"}}void 0===Qe&&(Qe=document.body.style.overflow,document.body.style.overflow="hidden")}(t),Ke&&(e.ontouchstart=function(e){1===e.targetTouches.length&&(Xe=e.targetTouches[0].clientY)},e.ontouchmove=function(t){1===t.targetTouches.length&&function(e,t){var n=e.targetTouches[0].clientY-Xe;!tt(e.target)&&(t&&0===t.scrollTop&&n>0||function(e){return!!e&&e.scrollHeight-e.scrollTop<=e.clientHeight}(t)&&n<0?nt(e):e.stopPropagation())}(t,e)},Je||(document.addEventListener("touchmove",nt,$e?{passive:!1}:void 0),Je=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},ot=function(e){e?(Ge=Ge.filter((function(t){return t.targetElement!==e})),Ke&&(e.ontouchstart=null,e.ontouchmove=null,Je&&0===Ge.length&&(document.removeEventListener("touchmove",nt,$e?{passive:!1}:void 0),Je=!1)),Ke?function(){if(void 0!==Ye){var e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);document.body.style.position=Ye.position,document.body.style.top=Ye.top,document.body.style.left=Ye.left,window.scrollTo(t,e),Ye=void 0}}():(void 0!==et&&(document.body.style.paddingRight=et,et=void 0),void 0!==Qe&&(document.body.style.overflow=Qe,Qe=void 0))):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")},it=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()}},at={"text/plain":"Text","text/html":"Url",default:"Text"},st="Copy to clipboard: #{key}, Enter";var lt=function(e,t){var n,r,o,i,a,s,l=!1;t||(t={}),n=t.debug||!1;try{if(o=it(),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=at[t.format]||at.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:st),window.prompt(r,e)}}finally{a&&("function"==typeof a.removeRange?a.removeRange(i):a.removeAllRanges()),s&&document.body.removeChild(s),o()}return l};const ct=e=>({id:e,type:"paragraph",nodeType:"block",children:[{text:""}]});function dt(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 ut={hoveredElement:null,isElementOptionsOpen:!1,nodeSettingsPos:null,dndState:Re,disableWhileDrag:!1,DRAG_MAP:new Map},ft=r.createContext([ut,{openNodeSettings:(e,t)=>{},closeNodeSettings:()=>{},hoverIn:(e,t)=>{},triggerPlusButton:e=>{},deleteNode:()=>{},duplicateNode:()=>{},copyLinkNode:()=>{},onDrop:e=>{},onDragEnd:e=>{},onDragEnter:e=>{},onDragStart:e=>{},changeHoveredNode:e=>{}}]),pt=({children:e})=>{const n=p(),[r,i]=(e=>{const[t,n]=o(!1),[r,i]=o(Re),[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=Ie(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(Re)},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(!1),v=Object.assign({hoveredElement:c,isElementOptionsOpen:u,nodeSettingsPos:a},r),g=s((()=>Object.assign({hoverIn:(e,t)=>{var n;if(u)return e.preventDefault();(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.skipSettings)||d(t)},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=ct(Ze());w.insertNodes(n,o,{at:r,select:!0}),d(o)}))},openNodeSettings:(e,t)=>{if(rt(document.body,{reserveScrollBarGap:!0}),h(!0),e.current){const t=e.current.getBoundingClientRect();l({left:t.left+t.width+10,top:t.top})}},closeNodeSettings:()=>{ot(document.body),h(!1),l(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 g.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),g.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=Ie(c);r.id=Ze(),w.insertNodes(n,r,{at:t,match:e=>_.isElement(e),mode:"highest",select:!0}),f.focus(n),d(null),g.closeNodeSettings()}))},copyLinkNode:()=>{0===window.location.hash.length?lt(`${window.location.href}#${null==c?void 0:c.id}`):lt(`${window.location.href.split("#")[0]}#${null==c?void 0:c.id}`),g.closeNodeSettings()}},i)),[c,u,r,n.children]),y=s((()=>[v,g]),[c,u,r,n.selection,n.children]);return t(ft.Provider,Object.assign({value:y},{children:e}))},ht=()=>a(ft);var vt="IMJgzRnZ",gt="nFfAiJWo",yt="DeARgIyF",mt="kyuzONcU",bt="_95up7F66",wt="_9d0T-cEo";xe(".IMJgzRnZ{align-items:center;background:linear-gradient(90deg,rgba(49,49,47,.99),#262625);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;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:#fff;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:#383835;color:#fff}._95up7F66{align-items:center;color:#fff;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 _t=n=>{var{onClose:r,style:o,element:i,render:a}=n,s=S(n,["onClose","style","element","render"]);const l=p(),[,c]=ht();m.isVoid(l,i);const d=()=>{var e;c.deleteNode(),null===(e=s.onDelete)||void 0===e||e.call(s)},u=()=>{var e;c.duplicateNode(),null===(e=s.onDuplicate)||void 0===e||e.call(s)},f=()=>{var e;c.copyLinkNode(),null===(e=s.onCopy)||void 0===e||e.call(s)};return t(Se,a?Object.assign({onClose:r},{children:t("div",Object.assign({style:o,className:vt},{children:a({handleDelete:d,handleDuplicate:u,handleCopy:f})}))}):Object.assign({onClose:r},{children:t("div",Object.assign({style:o,className:vt},{children:t("div",Object.assign({className:gt},{children:e("div",Object.assign({className:yt},{children:[e("button",Object.assign({type:"button",className:mt,onClick:d},{children:[t("div",Object.assign({className:bt},{children:t(Ae,{})})),t("div",Object.assign({className:wt},{children:"Delete"}))]})),e("button",Object.assign({type:"button",className:mt,onClick:u},{children:[t("div",Object.assign({className:bt},{children:t(Be,{})})),t("div",Object.assign({className:wt},{children:"Duplicate"}))]})),e("button",Object.assign({type:"button",className:mt,onClick:f},{children:[t("div",Object.assign({className:bt},{children:t(Fe,{})})),t("div",Object.assign({className:wt},{children:"Copy link to block"}))]}))]}))}))}))}))};var xt={};Object.defineProperty(xt,"__esModule",{value:!0});for(var Ot="undefined"!=typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),jt={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},Et={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:Ot?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},kt={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},Nt=1;Nt<20;Nt++)kt["f"+Nt]=111+Nt;function St(e,t,n){t&&!("byKey"in t)&&(n=t,t=null),Array.isArray(e)||(e=[e]);var r=e.map((function(e){return Dt(e,t)})),o=function(e){return r.some((function(t){return Pt(t,e)}))};return null==n?o:o(n)}function Dt(e,t){var n=t&&t.byKey,r={},o=(e=e.replace("++","+add")).split("+"),i=o.length;for(var a in jt)r[jt[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=At(f),v=jt[h];if(f.length>1&&!v&&!Et[f]&&!kt[h])throw new TypeError('Unknown modifier: "'+f+'"');1!==i&&v||(n?r.key=h:r.which=Ct(f)),v&&(r[v]=!p||null)}}catch(e){l=!0,c=e}finally{try{!s&&u.return&&u.return()}finally{if(l)throw c}}return r}function Pt(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 Ct(e){return e=At(e),kt[e]||e.toUpperCase().charCodeAt(0)}function At(e){return e=e.toLowerCase(),e=Et[e]||e}xt.default=St;var Tt=xt.isHotkey=St,Lt=xt.isCodeHotkey=function(e,t){return St(e,t)},Bt=xt.isKeyHotkey=function(e,t){return St(e,{byKey:!0},t)};xt.parseHotkey=Dt,xt.compareHotkey=Pt,xt.toKeyCode=Ct,xt.toKeyName=At;const Mt=({children:e,fallback:t=null})=>{const[n,r]=o(!1);return i((()=>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 Ft(e){return"[object Object]"===Object.prototype.toString.call(e)}function Rt(e){var t,n;return!1!==Ft(e)&&(void 0===(t=e.constructor)||!1!==Ft(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))}var Ht={isHistory:e=>Rt(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]))},It=new WeakMap,zt=new WeakMap,Wt={isHistoryEditor:e=>Ht.isHistory(e.history)&&m.isEditor(e),isMerging:e=>zt.get(e),isSaving:e=>It.get(e),redo(e){e.redo()},undo(e){e.undo()},withoutMerging(e,t){var n=Wt.isMerging(e);zt.set(e,!1),t(),zt.set(e,n)},withoutSaving(e,t){var n=Wt.isSaving(e);It.set(e,!1),t(),It.set(e,n)}},Ut=(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))),Vt=(e,t)=>"set_selection"!==e.type||null!=e.properties&&null!=e.newProperties,Zt=(e,t)=>!(!t||"set_selection"!==e.type||"set_selection"!==t.type),$t=e=>"set_selection"!==e.type;function qt(e){return!!Array.isArray(e)&&0!==e.length}const Kt="yoopta-content";var Gt="u-OdDyDx";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}");const Jt={margin:"1px 0",whiteSpace:"pre-wrap",wordBreak:"break-word",color:"inherit",fontSize:"inherit",lineHeight:"inherit",fontWeight:"inherit"},Xt=l((({attributes:e,children:n,placeholder:r,leaf:o})=>{const i=h();return t("span",Object.assign({},e,{"data-placeholder":r,style:Jt,className:_e({[Gt]:o.withPlaceholder&&r&&i})},{children:n}))}));Xt.displayName="TextLeaf";var Qt;function Yt(){return Yt=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},Yt.apply(this,arguments)}var en,tn=function(e){return n.createElement("svg",Yt({viewBox:"0 0 10 10",fill:"currentColor",style:{width:14,height:14,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),Qt||(Qt=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 nn(){return nn=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},nn.apply(this,arguments)}var rn=function(e){return n.createElement("svg",nn({viewBox:"0 0 16 16",fill:"currentColor",style:{width:16,height:16,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),en||(en=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"})))},on="yCQ-VdE5",an="b--398nS",sn="_6VhqH6wy",ln="k9i48GWd",cn="TNeDy6y5",dn="jVfkavqE",un="_87oFW01f";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}');const fn=({element:n,editor:r,values:o,handlers:i})=>{const a=c(null),{hoveredElement:s,isElementOptionsOpen:l,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(on,{[an]:b})},{children:[b&&l&&t(_t,{element:n,style:d||void 0,onClose:g}),t("button",Object.assign({type:"button",onMouseDown:y,className:_e(sn,ln),onClick:()=>v(n)},{children:t(rn,{})})),t("button",Object.assign({type:"button",onMouseDown:y,className:sn,onClick:()=>h(a,n),ref:a},{children:t(tn,{})}))]}))},pn=({children:n,element:r,attributes:o,nodeType:i,render:a,HTMLAttributes:l})=>{var c;const d=p(),[u,f]=ht(),h="inline"===i,{hoverIn:g,onDrop:v}=f,{dndState:y,DRAG_MAP:m}=u,b=s((()=>{var e,t;if(null===y.from.element||null===y.to.element)return{isDragging:!1,isDragOver:!1,isDragSelf:!1};const n=(null===(e=u.dndState.from.element)||void 0===e?void 0:e.id)===r.id,o=(null===(t=u.dndState.to.element)||void 0===t?void 0:t.id)===r.id;return{isDragging:n,isDragOver:o,isDragSelf:n&&o}}),[u.dndState.from,u.dndState.to]),w=null===(c=r.data)||void 0===c?void 0:c.skipSettings,{isDragging:_,isDragOver:x,isDragSelf:O}=b,j={opacity:_?.7:1};return m.set(r.id,r),h?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=>{w||g(e,r)},onDrop:v,className:_e(cn,{[dn]:x,[un]:O}),style:j},o,{children:[w?null:t(fn,{editor:d,element:r,handlers:f,values:u}),a({attributes:o,element:r,children:n,HTMLAttributes:l})]}))};pn.displayName="ElementWrapper";const hn={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"},gn={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"},vn={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},yn=e=>{const t=hn[e],n=gn[e],r=vn[e],o=t&&Bt(t),i=n&&Bt(n),a=r&&Bt(r);return e=>!(!o||!o(e))||(!(!i||!i(e))||!(!a||!a(e)))},mn={isBold:yn("bold"),isCompose:yn("compose"),isArrowLeft:yn("arrowLeft"),isArrowRight:yn("arrowRight"),isArrowUp:yn("arrowUp"),isArrowDown:yn("arrowDown"),isDeleteBackward:yn("deleteBackward"),isDeleteForward:yn("deleteForward"),isDeleteLineBackward:yn("deleteLineBackward"),isDeleteLineForward:yn("deleteLineForward"),isDeleteWordBackward:yn("deleteWordBackward"),isDeleteWordForward:yn("deleteWordForward"),isExtendBackward:yn("extendBackward"),isExtendForward:yn("extendForward"),isExtendLineBackward:yn("extendLineBackward"),isExtendLineForward:yn("extendLineForward"),isItalic:yn("italic"),isMoveLineBackward:yn("moveLineBackward"),isMoveLineForward:yn("moveLineForward"),isCtrlLeft:yn("ctrlLeft"),isCtrlRight:yn("ctrlRight"),isRedo:yn("redo"),isShiftEnter:yn("shiftEnter"),isEnter:yn("enter"),isTransposeCharacter:yn("transposeCharacter"),isUndo:yn("undo"),isSpace:yn("space"),isSelect:yn("select"),isTab:yn("tab"),isShiftTab:yn("shiftTab"),isBackspace:yn("backspace"),isCmdEnter:yn("cmdEnter"),isCmd:yn("cmd"),isEscape:yn("escape"),isKekceburek:yn("kekCeburek")},bn=(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),wn=(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 _n(e,t){var n,r;if(O.isText(e))return function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return e.replace(/[&<>"']/g,(e=>t[e]))}(e.text);const o=e.children.map((e=>_n(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 xn(e,t){return e.map((e=>_n(e,t))).join("")}const On={hotkeys:mn,defaultNode:ct(Ze())},jn=({editor:n,placeholder:o,marks:a,readOnly:l,children:u,plugins:p,className:h,PLUGINS_MAP:v})=>{i((()=>{const e=window.location.hash.length>0?window.location.hash.replace("#",""):null;if(e){const t=document.getElementById(e)||document.querySelector(`[data-element-id="${e}"]`);t&&window.scrollTo({top:t.offsetTop,behavior:"smooth"})}}),[]);const y=c(null),[{disableWhileDrag:x},{changeHoveredNode:O}]=ht(),E=x||l,k=s((()=>e=>{var r;const o=v[e.element.type];console.log("renderElement plugin",o);const i=function(e){return console.log("getRenderFunctionFactory",e),"function"==typeof e.renderer?e.renderer:e.renderer.editor}(o)(n,o);return t(pn,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}))}),[p,n]),N=s((()=>e=>{const t=[],[r,o]=e;return p.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]])&&j.includes(n.selection,o)&&j.isCollapsed(n.selection)&&t.push(Object.assign(Object.assign({},n.selection),{withPlaceholder:!0})),t}),[p,n]),S=s((()=>e=>{var r;const i=Object.assign({},e);let s;p.forEach((e=>{if(e.leaf){const t=e.leaf(n)(i);t&&(i.children=t)}})),null==a||a.forEach((e=>{i.leaf[e.type]&&(i.children=e.render(i))}));const l=null===(r=i.children.props)||void 0===r?void 0:r.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=v[null==l?void 0:l.type];s=null===(null==e?void 0:e.placeholder)?null:(null==e?void 0:e.placeholder)||o}return t(Xt,Object.assign({},i,{placeholder:s}))}),[p,n]),D=s((()=>{const e=p.map((e=>Object.keys(e.events||{}))).flat().filter(((e,t,n)=>n.indexOf(e)===t)),t={};return e.forEach((e=>{t[e]=function(t){p.forEach((r=>{var o;if(null===(o=r.events)||void 0===o?void 0:o[e]){r.events[e](n,On)(t)}}))}})),t}),[p,n]),P=d((e=>{m.withoutNormalizing(n,(()=>{var t;if(!n.selection)return;const r=ct(Ze());null==a||a.forEach((t=>{t.hotkey&&Bt(t.hotkey)(e)&&(e.preventDefault(),dt(n,t.type,!1))})),null===(t=D.onKeyDown)||void 0===t||t.call(D,e);const o=m.above(n,{match:e=>!m.isEditor(e),mode:"lowest"});if(mn.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 i=b.parent(n.selection.anchor.path),a=m.string(n,i),s=o&&o[0].type!==r.type;if(s&&0===a.length)return void w.setNodes(n,r,{at:i});if(m.isStart(n,n.selection.anchor,n.selection.anchor.path)&&s){const[e]=o;return w.setNodes(n,r,{at:i}),w.delete(n,{unit:"block"}),w.insertNodes(n,Ie(e),{at:b.next(i)}),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 O(r)}if(mn.isShiftEnter(e)){if(e.isDefaultPrevented())return;e.preventDefault(),n.insertText("\n")}if(mn.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 j.isExpanded(n.selection)||0===r.length?void w.select(n,[]):void w.select(n,t[1])}}))}),[]),C=s((()=>r.Children.count(u)>0?r.Children.map(u,(e=>r.isValidElement(e)?r.cloneElement(e,Object.assign(Object.assign({},e.props),{plugins:p,marks:null==a?void 0:a.map((e=>e.type)),editorRef:y,PLUGINS_MAP:v})):null)):null),[p,a,y.current]);return e("div",Object.assign({id:"yoopta-editor",className:h,ref:y,onMouseDown:e=>{l||(e.preventDefault(),e.currentTarget===e.target&&n.selection&&m.withoutNormalizing(n,(()=>{const e=[n.children.length-1,0],t=wn(n,e,"highest"),r=m.string(n,e);console.log("lastNode",t),console.log("lastNodeText",r);const 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}),O(t),f.focus(n);const i=ct(Ze());O(i),w.insertNodes(n,i,{at:[n.children.length],select:!0}),f.focus(n)})))}},{children:[C,t(g,Object.assign({id:"yoopta-contenteditable",renderLeaf:S,renderElement:k,readOnly:E,decorate:N,onCopy:e=>{if(e.preventDefault(),!n.selection)return;const t=xn(m.fragment(n,n.selection),n.plugins);return e.clipboardData.setData("text/html",t),e.clipboardData},autoFocus:!0,spellCheck:!0},D,{onKeyDown:P,onMouseDown:e=>{var t;null===(t=D.onMouseDown)||void 0===t||t.call(D,e),(e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()})(e)}}))]}))};function En(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var kn=new WeakMap,Nn=new WeakMap;class Sn{}class Dn extends Sn{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 Pn extends Sn{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 Cn=e=>Nn.get(e);function An(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 Tn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?An(Object(n),!0).forEach((function(t){En(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):An(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ln=new WeakSet,Bn=e=>{var t=[],n=e=>{if(null!=e){var r=t[t.length-1];if("string"==typeof e){var o={text:e};Ln.add(o),e=o}if(O.isText(e)){var i=e;O.isText(r)&&Ln.has(r)&&Ln.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 Sn))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 Dn?((e,t)=>{var n=e.text.length;kn.set(e,[n,t])})(a,e):e instanceof Pn&&((e,t)=>{var n=e.text.length;Nn.set(e,[n,t])})(a,e)}}};for(var r of e.flat(1/0))n(r);return t};function Mn(e,t,n){return Tn(Tn({},t),{},{children:Bn(n)})}function Fn(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 Rn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Fn(Object(n),!0).forEach((function(t){En(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Hn,In={anchor:function(e,t,n){return new Dn(t)},cursor:function(e,t,n){return[new Dn(t),new Pn(t)]},editor:(Hn=k,(e,t,n)=>{var r,o=[];for(var i of n)j.isRange(i)?r=i:o.push(i);var a,s=Bn(o),l={},c=Hn();for(var[d,u]of(Object.assign(c,t),c.children=s,E.texts(c))){var f=(a=d,kn.get(a)),p=Cn(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:Mn,focus:function(e,t,n){return new Pn(t)},fragment:function(e,t,n){return Bn(n)},selection:function(e,t,n){var r=n.find((e=>e instanceof Dn)),o=n.find((e=>e instanceof Pn));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 Tn({anchor:{offset:r.offset,path:r.path},focus:{offset:o.offset,path:o.path}},t)},text:function(e,t,n){var r=Bn(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 Ln.delete(o),Object.assign(o,t),o}},zn=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={}),Rt(n)||(o=[n].concat(o),n={}),a(t,n,o=o.filter((e=>Boolean(e))).flat())},Wn=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)=>Mn(0,Rn(Rn({},r),t),n)};for(var r in e)n(r);return t},Un=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{elements:t={}}=e,n=Wn(t),r=Rn(Rn(Rn({},In),n),e.creators);return zn(r)}();const Vn={DEL:()=>({strikethrough:!0}),EM:()=>({italic:!0}),I:()=>({italic:!0}),S:()=>({strikethrough:!0}),STRONG:()=>({bold:!0}),U:()=>({underline:!0})},Zn=(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=>Zn(e,t))).flat();if(0===l.length&&(l=[{text:""}]),"BODY"===e.nodeName)return Un("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 Un("element",t,l)}}if(O.isTextList(l))return Un("element",t.P.defineElement(),l);if(Vn[a]){const t=Vn[a](e);return l.map((e=>O.isText(e)?Un("text",t,e):e))}return l};function $n(e,t){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 Zn(r.body,n)}const qn=r.createContext({marks:{},plugins:{}}),Kn=({children:e,plugins:n,marks:r})=>{const o=p(),i=s((()=>{const e=me(n),t={};return e.forEach((e=>{const{createElement:n,defineElement:r,type:o,options:i}=e;t[e.type]={createElement:n,defineElement:r,type:o,options:i}})),t}),[n]),a=e=>{const t=m.marks(o);return!!(null==t?void 0:t[e])},l=s((()=>{const e={};return null==r||r.forEach((t=>{e[t.type]={toggle:e=>((e,t=!1)=>{t&&Object.keys(m.marks(o)||{}).forEach((e=>{m.removeMark(o,e)})),a(e)?m.removeMark(o,e):m.addMark(o,e,!0)})(t.type,null==e?void 0:e.only),isActive:a(t.type)}})),e}),[r,o.selection]),c=s((()=>({plugins:i,marks:l})),[o.selection,l,i]);return t(qn.Provider,Object.assign({value:c},{children:e}))},Gn=()=>a(qn),Jn=({key:e,value:n,plugins:r,marks:a,readOnly:l,children:c,onChange:u,placeholder:p,autoFocus:h=!0,offline:g,className:N})=>{const S=function(e){return"string"==typeof e?e:Kt}(g),[D,P]=o((()=>function(e,t,n){const r=[{id:Ze(),type:"paragraph",children:[{text:""}]}],o=qt(n)?n:r;if(!t)return localStorage.removeItem(e),o;try{const t=JSON.parse(localStorage.getItem(e)||"[]");return qt(t)?t:o}catch(t){return localStorage.removeItem(e),r}}(S,g,n))),C=d((e=>{if(u(e),P(e),!g)return;if(B.operations.some((e=>"set_selection"!==e.type)))try{const t=JSON.stringify(e);localStorage.setItem(S,t)}catch(e){}}),[g]),A=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}=A,B=s((()=>{let e=(e=>{const{insertData:t}=e;return e.insertData=n=>{if(e.selection&&j.isExpanded(e.selection))return;const r=n.getData("text/html");if(r){const t=$n(r,e.plugins);w.insertFragment(e,t)}else 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),a=j.equals(n,i);if(console.log({isAllNodesSelected:a,fullRange:i}),a)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=ct(Ze());w.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=b.parent(e.selection.anchor.path),r=E.get(e,n);_.isElement(r)&&m.isVoid(e,r)?m.insertNode(e,{id:Ze(),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=b.parent(e.selection.anchor.path),o=E.get(e,r);if(0===E.string(o).length&&b.hasPrevious(r)){const t=b.previous(r),n=E.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];Wt.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];Wt.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=Zt(e,s),c=Wt.isSaving(t),d=Wt.isMerging(t);if(null==c&&(c=Vt(e)),c){if(null==d&&(d=null!=a&&(0!==r.length||Ut(e,s)||l)),a&&d)l&&a.pop(),a.push(e);else{var u=[e];i.push(u)}for(;i.length>100;)i.shift();$t(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=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(h)try{const[,e]=m.first(B,[0]);w.select(B,{anchor:{path:e,offset:0},focus:{path:e,offset:0}}),f.focus(B)}catch(e){}}),[h,B]),t(y,Object.assign({editor:B,value:D,onChange:C},{children:t(Kn,Object.assign({plugins:r,marks:a},{children:t(pt,{children:t(jn,{editor:B,readOnly:l,placeholder:p,plugins:T,children:c,marks:a,PLUGINS_MAP:L,className:N})})}))}),e)},Xn=e=>t(Mt,{children:t(Jn,Object.assign({},e,{value:e.value,onChange:e.onChange}))});function Qn({type:e,hotkey:n,className:r}){return{type:e,hotkey:n,render:e=>t("span",Object.assign({},e.attributes,{className:r},{children:e.children}))}}const Yn={ElementOptions:_t,Overlay:Se};export{mn as HOTKEYS,Yn as UI_HELPERS,ve as YooptaPlugin,Qn as createYooptaMark,ye as createYooptaPlugin,_e as cx,Ie as deepClone,Xn as default,Ze as generateId,wn as getElementByPath,Lt as isCodeHotkey,bn as isElementActive,Tt as isHotkey,Bt as isKeyHotkey,qt as isValidYooptaNodes,me as mergePlugins,ht as useElementSettings,Gn as useYoopta};
13
+ */function Ft(e){return"[object Object]"===Object.prototype.toString.call(e)}function zt(e){var t,n;return!1!==Ft(e)&&(void 0===(t=e.constructor)||!1!==Ft(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))}var Ht={isHistory:e=>zt(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]))},It=new WeakMap,Rt=new WeakMap,Wt={isHistoryEditor:e=>Ht.isHistory(e.history)&&m.isEditor(e),isMerging:e=>Rt.get(e),isSaving:e=>It.get(e),redo(e){e.redo()},undo(e){e.undo()},withoutMerging(e,t){var n=Wt.isMerging(e);Rt.set(e,!1),t(),Rt.set(e,n)},withoutSaving(e,t){var n=Wt.isSaving(e);It.set(e,!1),t(),It.set(e,n)}},Ut=(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))),Vt=(e,t)=>"set_selection"!==e.type||null!=e.properties&&null!=e.newProperties,Zt=(e,t)=>!(!t||"set_selection"!==e.type||"set_selection"!==t.type),$t=e=>"set_selection"!==e.type;function qt(e){return!!Array.isArray(e)&&0!==e.length}const Kt="yoopta-content";var Gt="u-OdDyDx";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}");const Jt={margin:"1px 0",whiteSpace:"pre-wrap",wordBreak:"break-word",color:"inherit",fontSize:"inherit",lineHeight:"inherit",fontWeight:"inherit"},Xt=l((({attributes:e,children:n,placeholder:r,leaf:o})=>{const i=h();return t("span",Object.assign({},e,{"data-placeholder":r,style:Jt,className:_e({[Gt]:o.withPlaceholder&&r&&i})},{children:n}))}));Xt.displayName="TextLeaf";var Qt;function Yt(){return Yt=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},Yt.apply(this,arguments)}var en,tn=function(e){return n.createElement("svg",Yt({viewBox:"0 0 10 10",fill:"currentColor",style:{width:14,height:14,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),Qt||(Qt=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 nn(){return nn=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},nn.apply(this,arguments)}var rn=function(e){return n.createElement("svg",nn({viewBox:"0 0 16 16",fill:"currentColor",style:{width:16,height:16,display:"block",flexShrink:0,backfaceVisibility:"hidden"}},e),en||(en=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"})))},on="yCQ-VdE5",an="b--398nS",sn="_6VhqH6wy",ln="k9i48GWd",cn="TNeDy6y5",dn="jVfkavqE",un="_87oFW01f";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}');const fn=({element:n,editor:r,values:o,handlers:i})=>{const a=c(null),{hoveredElement:s,isElementOptionsOpen:l,nodeSettingsPos:d}=o,{onDragEnd:u,onDragStart:p,openNodeSettings:h,closeNodeSettings:v,triggerPlusButton:g}=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(on,{[an]:b})},{children:[b&&l&&t(_t,{element:n,style:d||void 0,onClose:v}),t("button",Object.assign({type:"button",onMouseDown:y,className:_e(sn,ln),onClick:()=>g(n)},{children:t(rn,{})})),t("button",Object.assign({type:"button",onMouseDown:y,className:sn,onClick:()=>h(a,n),ref:a},{children:t(tn,{})}))]}))},pn=({children:n,element:r,attributes:o,nodeType:i,render:a,HTMLAttributes:l})=>{var c;const d=p(),[u,f]=ht(),h="inline"===i,{hoverIn:v,onDrop:g}=f,{dndState:y,DRAG_MAP:m}=u,b=s((()=>{var e,t;if(null===y.from.element||null===y.to.element)return{isDragging:!1,isDragOver:!1,isDragSelf:!1};const n=(null===(e=u.dndState.from.element)||void 0===e?void 0:e.id)===r.id,o=(null===(t=u.dndState.to.element)||void 0===t?void 0:t.id)===r.id;return{isDragging:n,isDragOver:o,isDragSelf:n&&o}}),[u.dndState.from,u.dndState.to]),w=null===(c=r.data)||void 0===c?void 0:c.skipSettings,{isDragging:_,isDragOver:x,isDragSelf:O}=b,j={opacity:_?.7:1};return m.set(r.id,r),h?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=>{w||v(e,r)},onDrop:g,className:_e(cn,{[dn]:x,[un]:O}),style:j},o,{children:[w?null:t(fn,{editor:d,element:r,handlers:f,values:u}),a({attributes:o,element:r,children:n,HTMLAttributes:l})]}))};pn.displayName="ElementWrapper";const hn={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"},vn={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"},gn={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},yn=e=>{const t=hn[e],n=vn[e],r=gn[e],o=t&&Bt(t),i=n&&Bt(n),a=r&&Bt(r);return e=>!(!o||!o(e))||(!(!i||!i(e))||!(!a||!a(e)))},mn={isBold:yn("bold"),isCompose:yn("compose"),isArrowLeft:yn("arrowLeft"),isArrowRight:yn("arrowRight"),isArrowUp:yn("arrowUp"),isArrowDown:yn("arrowDown"),isDeleteBackward:yn("deleteBackward"),isDeleteForward:yn("deleteForward"),isDeleteLineBackward:yn("deleteLineBackward"),isDeleteLineForward:yn("deleteLineForward"),isDeleteWordBackward:yn("deleteWordBackward"),isDeleteWordForward:yn("deleteWordForward"),isExtendBackward:yn("extendBackward"),isExtendForward:yn("extendForward"),isExtendLineBackward:yn("extendLineBackward"),isExtendLineForward:yn("extendLineForward"),isItalic:yn("italic"),isMoveLineBackward:yn("moveLineBackward"),isMoveLineForward:yn("moveLineForward"),isCtrlLeft:yn("ctrlLeft"),isCtrlRight:yn("ctrlRight"),isRedo:yn("redo"),isShiftEnter:yn("shiftEnter"),isEnter:yn("enter"),isTransposeCharacter:yn("transposeCharacter"),isUndo:yn("undo"),isSpace:yn("space"),isSelect:yn("select"),isTab:yn("tab"),isShiftTab:yn("shiftTab"),isBackspace:yn("backspace"),isCmdEnter:yn("cmdEnter"),isCmd:yn("cmd"),isEscape:yn("escape"),isKekceburek:yn("kekCeburek")},bn=(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),wn=(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 _n(e,t){var n,r;if(O.isText(e))return function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return e.replace(/[&<>"']/g,(e=>t[e]))}(e.text);const o=e.children.map((e=>_n(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 xn(e,t){return e.map((e=>_n(e,t))).join("")}const On={hotkeys:mn,defaultNode:ct(Ze())},jn=({editor:n,placeholder:o,marks:a,readOnly:l,children:u,plugins:p,className:h,PLUGINS_MAP:g})=>{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 y=c(null),[{disableWhileDrag:x},{changeHoveredNode:O}]=ht(),E=x||l,k=s((()=>e=>{var r;const o=g[e.element.type];if(!o)return null;const i=function(e){return"function"==typeof e.renderer?e.renderer:e.renderer.editor}(o)(n,o);return t(pn,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}))}),[p,n]),N=s((()=>e=>{const t=[],[r,o]=e;return p.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]])&&j.includes(n.selection,o)&&j.isCollapsed(n.selection)&&t.push(Object.assign(Object.assign({},n.selection),{withPlaceholder:!0})),t}),[p,n]),S=s((()=>e=>{var r;const i=Object.assign({},e);let s;p.forEach((e=>{if(e.leaf){const t=e.leaf(n)(i);t&&(i.children=t)}})),null==a||a.forEach((e=>{i.leaf[e.type]&&(i.children=e.render(i))}));const l=null===(r=i.children.props)||void 0===r?void 0:r.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=g[null==l?void 0:l.type];s=null===(null==e?void 0:e.placeholder)?null:(null==e?void 0:e.placeholder)||o}return t(Xt,Object.assign({},i,{placeholder:s}))}),[p,n]),D=s((()=>{const e=p.map((e=>Object.keys(e.events||{}))).flat().filter(((e,t,n)=>n.indexOf(e)===t)),t={};return e.forEach((e=>{t[e]=function(t){p.forEach((r=>{var o;if(null===(o=r.events)||void 0===o?void 0:o[e]){r.events[e](n,On)(t)}}))}})),t}),[p,n]),P=d((e=>{m.withoutNormalizing(n,(()=>{var t;if(!n.selection)return;const r=ct(Ze());null==a||a.forEach((t=>{t.hotkey&&Bt(t.hotkey)(e)&&(e.preventDefault(),dt(n,t.type,!1))})),null===(t=D.onKeyDown)||void 0===t||t.call(D,e);const o=m.above(n,{match:e=>!m.isEditor(e),mode:"lowest"});if(mn.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 i=b.parent(n.selection.anchor.path),a=m.string(n,i),s=o&&o[0].type!==r.type;if(s&&0===a.length)return void w.setNodes(n,r,{at:i});if(m.isStart(n,n.selection.anchor,n.selection.anchor.path)&&s){const[e]=o;return w.setNodes(n,r,{at:i}),w.delete(n,{unit:"block"}),w.insertNodes(n,Ie(e),{at:b.next(i)}),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 O(r)}if(mn.isShiftEnter(e)){if(e.isDefaultPrevented())return;e.preventDefault(),n.insertText("\n")}if(mn.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 j.isExpanded(n.selection)||0===r.length?void w.select(n,[]):void w.select(n,t[1])}}))}),[]),C=s((()=>r.Children.count(u)>0?r.Children.map(u,(e=>r.isValidElement(e)?r.cloneElement(e,Object.assign(Object.assign({},e.props),{plugins:p,marks:null==a?void 0:a.map((e=>e.type)),editorRef:y,PLUGINS_MAP:g})):null)):null),[p,a,y.current]);return e("div",Object.assign({id:"yoopta-editor",className:h,ref:y,onMouseDown:e=>{l||(e.preventDefault(),e.currentTarget===e.target&&n.selection&&m.withoutNormalizing(n,(()=>{const e=[n.children.length-1,0],t=wn(n,e,"highest"),r=m.string(n,e);console.log("lastNode",t),console.log("lastNodeText",r);const 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}),O(t),f.focus(n);const i=ct(Ze());O(i),w.insertNodes(n,i,{at:[n.children.length],select:!0}),f.focus(n)})))}},{children:[C,t(v,Object.assign({id:"yoopta-contenteditable",renderLeaf:S,renderElement:k,readOnly:E,decorate:N,onCopy:e=>{if(e.preventDefault(),!n.selection)return;const t=xn(m.fragment(n,n.selection),n.plugins);return e.clipboardData.setData("text/html",t),e.clipboardData},autoFocus:!0,spellCheck:!0},D,{onKeyDown:P,onMouseDown:e=>{var t;null===(t=D.onMouseDown)||void 0===t||t.call(D,e),(e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()})(e)}}))]}))};function En(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var kn=new WeakMap,Nn=new WeakMap;class Sn{}class Dn extends Sn{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 Pn extends Sn{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 Cn=e=>Nn.get(e);function An(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 Tn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?An(Object(n),!0).forEach((function(t){En(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):An(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ln=new WeakSet,Bn=e=>{var t=[],n=e=>{if(null!=e){var r=t[t.length-1];if("string"==typeof e){var o={text:e};Ln.add(o),e=o}if(O.isText(e)){var i=e;O.isText(r)&&Ln.has(r)&&Ln.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 Sn))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 Dn?((e,t)=>{var n=e.text.length;kn.set(e,[n,t])})(a,e):e instanceof Pn&&((e,t)=>{var n=e.text.length;Nn.set(e,[n,t])})(a,e)}}};for(var r of e.flat(1/0))n(r);return t};function Mn(e,t,n){return Tn(Tn({},t),{},{children:Bn(n)})}function Fn(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?Fn(Object(n),!0).forEach((function(t){En(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Hn,In={anchor:function(e,t,n){return new Dn(t)},cursor:function(e,t,n){return[new Dn(t),new Pn(t)]},editor:(Hn=k,(e,t,n)=>{var r,o=[];for(var i of n)j.isRange(i)?r=i:o.push(i);var a,s=Bn(o),l={},c=Hn();for(var[d,u]of(Object.assign(c,t),c.children=s,E.texts(c))){var f=(a=d,kn.get(a)),p=Cn(d);if(null!=f){var[h]=f;l.anchor={path:u,offset:h}}if(null!=p){var[v]=p;l.focus={path:u,offset:v}}}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:Mn,focus:function(e,t,n){return new Pn(t)},fragment:function(e,t,n){return Bn(n)},selection:function(e,t,n){var r=n.find((e=>e instanceof Dn)),o=n.find((e=>e instanceof Pn));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 Tn({anchor:{offset:r.offset,path:r.path},focus:{offset:o.offset,path:o.path}},t)},text:function(e,t,n){var r=Bn(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 Ln.delete(o),Object.assign(o,t),o}},Rn=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={}),zt(n)||(o=[n].concat(o),n={}),a(t,n,o=o.filter((e=>Boolean(e))).flat())},Wn=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)=>Mn(0,zn(zn({},r),t),n)};for(var r in e)n(r);return t},Un=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{elements:t={}}=e,n=Wn(t),r=zn(zn(zn({},In),n),e.creators);return Rn(r)}();const Vn={DEL:()=>({strikethrough:!0}),EM:()=>({italic:!0}),I:()=>({italic:!0}),S:()=>({strikethrough:!0}),STRONG:()=>({bold:!0}),U:()=>({underline:!0})},Zn=(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=>Zn(e,t))).flat();if(0===l.length&&(l=[{text:""}]),"BODY"===e.nodeName)return Un("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 Un("element",t,l)}}if(O.isTextList(l))return Un("element",t.P.defineElement(),l);if(Vn[a]){const t=Vn[a](e);return l.map((e=>O.isText(e)?Un("text",t,e):e))}return l};function $n(e,t){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 Zn(r.body,n)}const qn=r.createContext({marks:{},elements:{}}),Kn=({children:e,plugins:n,marks:r})=>{const o=p(),i=s((()=>{const e=me(n),t={};return e.forEach((e=>{const{createElement:n,defineElement:r,type:i,hasParent:a}=e;a||(t[e.type]={create:n,define:r,toggle:t=>((e,t)=>{m.withoutNormalizing(o,(()=>{var n;if(!o.selection)return;const{offset:r,path:i}=o.selection.anchor,{shouldDeleteText:a}=t||{};a&&w.delete(o,{at:{anchor:{path:i,offset:0},focus:{path:i,offset:r}}});const s=m.above(o,{at:o.selection,mode:"highest",match:e=>!m.isEditor(e)&&_.isElement(e)}),[l,c]=m.parent(o,b.parent(o.selection.anchor.path)),[d]=s||[];(null==d?void 0:d.type)!==e.type?(_.isElement(l)&&!m.isEditor(l)&&w.unwrapNodes(o,{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,o)):w.setNodes(o,ct(Ze()),{mode:"highest",match:e=>!m.isEditor(e)&&_.isElement(e)})}))})(e,t),type:i})})),t}),[n,o.selection]),a=e=>{const t=m.marks(o);return!!(null==t?void 0:t[e])},l=s((()=>{const e={};return null==r||r.forEach((t=>{e[t.type]={toggle:e=>((e,t=!1)=>{t&&Object.keys(m.marks(o)||{}).forEach((e=>{m.removeMark(o,e)})),a(e)?m.removeMark(o,e):m.addMark(o,e,!0)})(t.type,null==e?void 0:e.only),isActive:a(t.type)}})),e}),[r,o.selection]),c=s((()=>({elements:i,marks:l})),[o.selection,l,i]);return t(qn.Provider,Object.assign({value:c},{children:e}))},Gn=()=>a(qn),Jn=()=>a(qn).marks,Xn=()=>a(qn).elements,Qn=({key:e,value:n,plugins:r,marks:a,readOnly:l,children:c,onChange:u,placeholder:p,autoFocus:h=!0,offline:v,className:N})=>{const S=function(e){return"string"==typeof e?e:Kt}(v),[D,P]=o((()=>function(e,t,n){const r=[{id:Ze(),type:"paragraph",children:[{text:""}]}],o=qt(n)?n:r;if(!t)return localStorage.removeItem(e),o;try{const t=JSON.parse(localStorage.getItem(e)||"[]");return qt(t)?t:o}catch(t){return localStorage.removeItem(e),r}}(S,v,n))),C=d((e=>{if(u(e),P(e),!v)return;if(B.operations.some((e=>"set_selection"!==e.type)))try{const t=JSON.stringify(e);localStorage.setItem(S,t)}catch(e){}}),[v]),A=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}=A,B=s((()=>{let e=(e=>{const{insertData:t}=e;return e.insertData=n=>{if(e.selection&&j.isExpanded(e.selection))return;const r=n.getData("text/html");if(r){const t=$n(r,e.plugins);w.insertFragment(e,t)}else 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),a=j.equals(n,i);if(console.log({isAllNodesSelected:a,fullRange:i}),a)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=ct(Ze());w.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=b.parent(e.selection.anchor.path),r=E.get(e,n);_.isElement(r)&&m.isVoid(e,r)?m.insertNode(e,{id:Ze(),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=b.parent(e.selection.anchor.path),o=E.get(e,r);if(0===E.string(o).length&&b.hasPrevious(r)){const t=b.previous(r),n=E.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];Wt.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];Wt.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=Zt(e,s),c=Wt.isSaving(t),d=Wt.isMerging(t);if(null==c&&(c=Vt(e)),c){if(null==d&&(d=null!=a&&(0!==r.length||Ut(e,s)||l)),a&&d)l&&a.pop(),a.push(e);else{var u=[e];i.push(u)}for(;i.length>100;)i.shift();$t(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=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})(g(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(h)try{const[,e]=m.first(B,[0]);w.select(B,{anchor:{path:e,offset:0},focus:{path:e,offset:0}}),f.focus(B)}catch(e){}}),[h,B]),t(y,Object.assign({editor:B,value:D,onChange:C},{children:t(Kn,Object.assign({plugins:r,marks:a,tools:c},{children:t(pt,{children:t(jn,{editor:B,readOnly:l,placeholder:p,plugins:T,children:c,marks:a,PLUGINS_MAP:L,className:N})})}))}),e)},Yn=e=>t(Mt,{children:t(Qn,Object.assign({},e,{value:e.value,onChange:e.onChange}))});function er({type:e,hotkey:n,className:r}){return{type:e,hotkey:n,render:e=>t("span",Object.assign({},e.attributes,{className:r},{children:e.children}))}}const tr={ElementOptions:_t,Overlay:Se};export{mn as HOTKEYS,tr as UI_HELPERS,ge as YooptaPlugin,er as createYooptaMark,ye as createYooptaPlugin,_e as cx,Ie as deepClone,Yn as default,Ze as generateId,wn as getElementByPath,Lt as isCodeHotkey,bn as isElementActive,Tt as isHotkey,Bt as isKeyHotkey,qt as isValidYooptaNodes,me as mergePlugins,ht as useElementSettings,Xn as useElements,Jn as useMarks,Gn as useYoopta};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoopta/editor",
3
- "version": "1.9.5-rc",
3
+ "version": "1.9.7-rc",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "type": "module",