scrible 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/scrible.cjs.js +8 -8
- package/dist/scrible.es.js +356 -349
- package/dist/scrible.umd.js +9 -9
- package/package.json +1 -1
package/dist/scrible.cjs.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
2
|
-
`+ue+t}}var de=!1,G;{var
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("react"),l=require("slate"),P=require("slate-react"),qt=require("slate-history"),ee=require("escape-html");var te={exports:{}},q={};var We;function Yt(){if(We)return q;We=1;var e=w,r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function c(u,p,b){var y,g={},h=null,E=null;b!==void 0&&(h=""+b),p.key!==void 0&&(h=""+p.key),p.ref!==void 0&&(E=p.ref);for(y in p)a.call(p,y)&&!d.hasOwnProperty(y)&&(g[y]=p[y]);if(u&&u.defaultProps)for(y in p=u.defaultProps,p)g[y]===void 0&&(g[y]=p[y]);return{$$typeof:r,type:u,key:h,ref:E,props:g,_owner:o.current}}return q.Fragment=n,q.jsx=c,q.jsxs=c,q}var Y={};var qe;function Kt(){return qe||(qe=1,process.env.NODE_ENV!=="production"&&(function(){var e=w,r=Symbol.for("react.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),u=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),y=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),E=Symbol.for("react.offscreen"),D=Symbol.iterator,$="@@iterator";function I(t){if(t===null||typeof t!="object")return null;var i=D&&t[D]||t[$];return typeof i=="function"?i:null}var N=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function C(t){{for(var i=arguments.length,f=new Array(i>1?i-1:0),m=1;m<i;m++)f[m-1]=arguments[m];ie("error",t,f)}}function ie(t,i,f){{var m=N.ReactDebugCurrentFrame,k=m.getStackAddendum();k!==""&&(i+="%s",f=f.concat([k]));var j=f.map(function(x){return String(x)});j.unshift("Warning: "+i),Function.prototype.apply.call(console[t],console,j)}}var ft=!1,ht=!1,pt=!1,mt=!1,gt=!1,ye;ye=Symbol.for("react.module.reference");function vt(t){return!!(typeof t=="string"||typeof t=="function"||t===a||t===d||gt||t===o||t===b||t===y||mt||t===E||ft||ht||pt||typeof t=="object"&&t!==null&&(t.$$typeof===h||t.$$typeof===g||t.$$typeof===c||t.$$typeof===u||t.$$typeof===p||t.$$typeof===ye||t.getModuleId!==void 0))}function bt(t,i,f){var m=t.displayName;if(m)return m;var k=i.displayName||i.name||"";return k!==""?f+"("+k+")":f}function Ee(t){return t.displayName||"Context"}function L(t){if(t==null)return null;if(typeof t.tag=="number"&&C("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case a:return"Fragment";case n:return"Portal";case d:return"Profiler";case o:return"StrictMode";case b:return"Suspense";case y:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case u:var i=t;return Ee(i)+".Consumer";case c:var f=t;return Ee(f._context)+".Provider";case p:return bt(t,t.render,"ForwardRef");case g:var m=t.displayName||null;return m!==null?m:L(t.type)||"Memo";case h:{var k=t,j=k._payload,x=k._init;try{return L(x(j))}catch{return null}}}return null}var A=Object.assign,U=0,we,ke,je,Ce,Re,Te,Ne;function ze(){}ze.__reactDisabledLog=!0;function xt(){{if(U===0){we=console.log,ke=console.info,je=console.warn,Ce=console.error,Re=console.group,Te=console.groupCollapsed,Ne=console.groupEnd;var t={configurable:!0,enumerable:!0,value:ze,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}U++}}function yt(){{if(U--,U===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:A({},t,{value:we}),info:A({},t,{value:ke}),warn:A({},t,{value:je}),error:A({},t,{value:Ce}),group:A({},t,{value:Re}),groupCollapsed:A({},t,{value:Te}),groupEnd:A({},t,{value:Ne})})}U<0&&C("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ce=N.ReactCurrentDispatcher,ue;function X(t,i,f){{if(ue===void 0)try{throw Error()}catch(k){var m=k.stack.trim().match(/\n( *(at )?)/);ue=m&&m[1]||""}return`
|
|
2
|
+
`+ue+t}}var de=!1,G;{var Et=typeof WeakMap=="function"?WeakMap:Map;G=new Et}function Me(t,i){if(!t||de)return"";{var f=G.get(t);if(f!==void 0)return f}var m;de=!0;var k=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var j;j=ce.current,ce.current=null,xt();try{if(i){var x=function(){throw Error()};if(Object.defineProperty(x.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(x,[])}catch(M){m=M}Reflect.construct(t,[],x)}else{try{x.call()}catch(M){m=M}t.call(x.prototype)}}else{try{throw Error()}catch(M){m=M}t()}}catch(M){if(M&&m&&typeof M.stack=="string"){for(var v=M.stack.split(`
|
|
3
3
|
`),z=m.stack.split(`
|
|
4
|
-
`),R=v.length-1,T=z.length-1;R>=1&&T>=0&&v[R]!==z[T];)T--;for(;R>=1&&T>=0;R--,T--)if(v[R]!==z[T]){if(R!==1||T!==1)do if(R--,T--,T<0||v[R]!==z[T]){var
|
|
5
|
-
`+v[R].replace(" at new "," at ");return t.displayName&&
|
|
4
|
+
`),R=v.length-1,T=z.length-1;R>=1&&T>=0&&v[R]!==z[T];)T--;for(;R>=1&&T>=0;R--,T--)if(v[R]!==z[T]){if(R!==1||T!==1)do if(R--,T--,T<0||v[R]!==z[T]){var _=`
|
|
5
|
+
`+v[R].replace(" at new "," at ");return t.displayName&&_.includes("<anonymous>")&&(_=_.replace("<anonymous>",t.displayName)),typeof t=="function"&&G.set(t,_),_}while(R>=1&&T>=0);break}}}finally{de=!1,ce.current=j,yt(),Error.prepareStackTrace=k}var F=t?t.displayName||t.name:"",O=F?X(F):"";return typeof t=="function"&&G.set(t,O),O}function wt(t,i,f){return Me(t,!1)}function kt(t){var i=t.prototype;return!!(i&&i.isReactComponent)}function Q(t,i,f){if(t==null)return"";if(typeof t=="function")return Me(t,kt(t));if(typeof t=="string")return X(t);switch(t){case b:return X("Suspense");case y:return X("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case p:return wt(t.render);case g:return Q(t.type,i,f);case h:{var m=t,k=m._payload,j=m._init;try{return Q(j(k),i,f)}catch{}}}return""}var W=Object.prototype.hasOwnProperty,Se={},_e=N.ReactDebugCurrentFrame;function Z(t){if(t){var i=t._owner,f=Q(t.type,t._source,i?i.type:null);_e.setExtraStackFrame(f)}else _e.setExtraStackFrame(null)}function jt(t,i,f,m,k){{var j=Function.call.bind(W);for(var x in t)if(j(t,x)){var v=void 0;try{if(typeof t[x]!="function"){var z=Error((m||"React class")+": "+f+" type `"+x+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[x]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw z.name="Invariant Violation",z}v=t[x](i,x,m,f,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(R){v=R}v&&!(v instanceof Error)&&(Z(k),C("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",m||"React class",f,x,typeof v),Z(null)),v instanceof Error&&!(v.message in Se)&&(Se[v.message]=!0,Z(k),C("Failed %s type: %s",f,v.message),Z(null))}}}var Ct=Array.isArray;function fe(t){return Ct(t)}function Rt(t){{var i=typeof Symbol=="function"&&Symbol.toStringTag,f=i&&t[Symbol.toStringTag]||t.constructor.name||"Object";return f}}function Tt(t){try{return De(t),!1}catch{return!0}}function De(t){return""+t}function Pe(t){if(Tt(t))return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Rt(t)),De(t)}var $e=N.ReactCurrentOwner,Nt={key:!0,ref:!0,__self:!0,__source:!0},Ie,Le;function zt(t){if(W.call(t,"ref")){var i=Object.getOwnPropertyDescriptor(t,"ref").get;if(i&&i.isReactWarning)return!1}return t.ref!==void 0}function Mt(t){if(W.call(t,"key")){var i=Object.getOwnPropertyDescriptor(t,"key").get;if(i&&i.isReactWarning)return!1}return t.key!==void 0}function St(t,i){typeof t.ref=="string"&&$e.current}function _t(t,i){{var f=function(){Ie||(Ie=!0,C("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",i))};f.isReactWarning=!0,Object.defineProperty(t,"key",{get:f,configurable:!0})}}function Dt(t,i){{var f=function(){Le||(Le=!0,C("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",i))};f.isReactWarning=!0,Object.defineProperty(t,"ref",{get:f,configurable:!0})}}var Pt=function(t,i,f,m,k,j,x){var v={$$typeof:r,type:t,key:i,ref:f,props:x,_owner:j};return v._store={},Object.defineProperty(v._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(v,"_self",{configurable:!1,enumerable:!1,writable:!1,value:m}),Object.defineProperty(v,"_source",{configurable:!1,enumerable:!1,writable:!1,value:k}),Object.freeze&&(Object.freeze(v.props),Object.freeze(v)),v};function $t(t,i,f,m,k){{var j,x={},v=null,z=null;f!==void 0&&(Pe(f),v=""+f),Mt(i)&&(Pe(i.key),v=""+i.key),zt(i)&&(z=i.ref,St(i,k));for(j in i)W.call(i,j)&&!Nt.hasOwnProperty(j)&&(x[j]=i[j]);if(t&&t.defaultProps){var R=t.defaultProps;for(j in R)x[j]===void 0&&(x[j]=R[j])}if(v||z){var T=typeof t=="function"?t.displayName||t.name||"Unknown":t;v&&_t(x,T),z&&Dt(x,T)}return Pt(t,v,z,k,m,$e.current,x)}}var he=N.ReactCurrentOwner,Ae=N.ReactDebugCurrentFrame;function H(t){if(t){var i=t._owner,f=Q(t.type,t._source,i?i.type:null);Ae.setExtraStackFrame(f)}else Ae.setExtraStackFrame(null)}var pe;pe=!1;function me(t){return typeof t=="object"&&t!==null&&t.$$typeof===r}function Oe(){{if(he.current){var t=L(he.current.type);if(t)return`
|
|
6
6
|
|
|
7
|
-
Check the render method of \``+t+"`."}return""}}function It(t){return""}var He={};function
|
|
7
|
+
Check the render method of \``+t+"`."}return""}}function It(t){return""}var He={};function Lt(t){{var i=Oe();if(!i){var f=typeof t=="string"?t:t.displayName||t.name;f&&(i=`
|
|
8
8
|
|
|
9
|
-
Check the top-level render call using <`+
|
|
9
|
+
Check the top-level render call using <`+f+">.")}return i}}function Fe(t,i){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var f=Lt(i);if(He[f])return;He[f]=!0;var m="";t&&t._owner&&t._owner!==he.current&&(m=" It was passed a child from "+L(t._owner.type)+"."),H(t),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',f,m),H(null)}}function Be(t,i){{if(typeof t!="object")return;if(fe(t))for(var f=0;f<t.length;f++){var m=t[f];me(m)&&Fe(m,i)}else if(me(t))t._store&&(t._store.validated=!0);else if(t){var k=I(t);if(typeof k=="function"&&k!==t.entries)for(var j=k.call(t),x;!(x=j.next()).done;)me(x.value)&&Fe(x.value,i)}}}function At(t){{var i=t.type;if(i==null||typeof i=="string")return;var f;if(typeof i=="function")f=i.propTypes;else if(typeof i=="object"&&(i.$$typeof===p||i.$$typeof===g))f=i.propTypes;else return;if(f){var m=L(i);jt(f,t.props,"prop",m,t)}else if(i.PropTypes!==void 0&&!pe){pe=!0;var k=L(i);C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",k||"Unknown")}typeof i.getDefaultProps=="function"&&!i.getDefaultProps.isReactClassApproved&&C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ot(t){{for(var i=Object.keys(t.props),f=0;f<i.length;f++){var m=i[f];if(m!=="children"&&m!=="key"){H(t),C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",m),H(null);break}}t.ref!==null&&(H(t),C("Invalid attribute `ref` supplied to `React.Fragment`."),H(null))}}var Ve={};function Ue(t,i,f,m,k,j){{var x=vt(t);if(!x){var v="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(v+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var z=It();z?v+=z:v+=Oe();var R;t===null?R="null":fe(t)?R="array":t!==void 0&&t.$$typeof===r?(R="<"+(L(t.type)||"Unknown")+" />",v=" Did you accidentally export a JSX literal instead of a component?"):R=typeof t,C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",R,v)}var T=$t(t,i,f,k,j);if(T==null)return T;if(x){var _=i.children;if(_!==void 0)if(m)if(fe(_)){for(var F=0;F<_.length;F++)Be(_[F],t);Object.freeze&&Object.freeze(_)}else C("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Be(_,t)}if(W.call(i,"key")){var O=L(t),M=Object.keys(i).filter(function(Wt){return Wt!=="key"}),ge=M.length>0?"{key: someKey, "+M.join(": ..., ")+": ...}":"{key: someKey}";if(!Ve[O+ge]){var Ut=M.length>0?"{"+M.join(": ..., ")+": ...}":"{}";C(`A props object containing a "key" prop is being spread into JSX:
|
|
10
10
|
let props = %s;
|
|
11
11
|
<%s {...props} />
|
|
12
12
|
React keys must be passed directly to JSX without using spread:
|
|
13
13
|
let props = %s;
|
|
14
|
-
<%s key={someKey} {...props} />`,ge,O,Ut,O),Ve[O+ge]=!0}}return t===a?Ot(T):Lt(T),T}}function Ht(t,i,d){return Ue(t,i,d,!0)}function Ft(t,i,d){return Ue(t,i,d,!1)}var Bt=Ft,Vt=Ht;Y.Fragment=a,Y.jsx=Bt,Y.jsxs=Vt})()),Y}var Ye;function Jt(){return Ye||(Ye=1,process.env.NODE_ENV==="production"?te.exports=Yt():te.exports=Kt()),te.exports}var s=Jt();const B=(e,r)=>{const n=V(e,r);if(r.startsWith("font-size-")){o.Editor.removeMark(e,"font-size-small"),o.Editor.removeMark(e,"font-size-normal"),o.Editor.removeMark(e,"font-size-large"),o.Editor.removeMark(e,"font-size-extra-large"),n||o.Editor.addMark(e,r,!0);return}n?o.Editor.removeMark(e,r):o.Editor.addMark(e,r,!0)},V=(e,r)=>{const n=o.Editor.marks(e);return n?n[r]===!0:!1},se=(e,r)=>{r?o.Editor.addMark(e,"color",r):o.Editor.removeMark(e,"color")},et=e=>o.Editor.marks(e)?.color||null,ae=(e,r)=>{r?o.Editor.addMark(e,"backgroundColor",r):o.Editor.removeMark(e,"backgroundColor")},tt=e=>o.Editor.marks(e)?.backgroundColor||null,oe=(e,r)=>{const n=le(e,r),a=Ke.includes(r);o.Transforms.unwrapNodes(e,{match:u=>!o.Editor.isEditor(u)&&o.Element.isElement(u)&&Ke.includes(u.type),split:!0});let l;if(n?l={type:"paragraph"}:a?l={type:"list-item"}:l={type:r},o.Transforms.setNodes(e,l),!n&&a){const u={type:r,children:[]};o.Transforms.wrapNodes(e,u)}},J=(e,r)=>{o.Transforms.setNodes(e,{align:r},{match:n=>o.Element.isElement(n)&&o.Editor.isBlock(e,n),split:!0})},le=(e,r,n="type")=>{const{selection:a}=e;if(!a)return!1;const[l]=Array.from(o.Editor.nodes(e,{at:o.Editor.unhangRange(e,a),match:u=>!o.Editor.isEditor(u)&&o.Element.isElement(u)&&u[n]===r}));return!!l},Ke=["numbered-list","bulleted-list"],be=(e,r,n="")=>{const l={type:"image",url:r,alt:n,width:"auto",height:"auto",children:[{text:""}]};o.Transforms.insertNodes(e,l),o.Transforms.insertNodes(e,{type:"paragraph",children:[{text:""}]})},rt=e=>{if(!e||!Xt(e))return!1;const r=new URL(e).pathname.split(".").pop();return["jpg","jpeg","png","gif","webp","svg"].includes(r.toLowerCase())},Xt=e=>{try{return new URL(e),!0}catch{return!1}},nt=(e,r)=>{e.selection&&st(e,r)},st=(e,r)=>{ot(e)&&at(e);const{selection:n}=e,a=n&&o.Range.isCollapsed(n),l={type:"link",url:r,children:a?[{text:r}]:[]};a?o.Transforms.insertNodes(e,l):(o.Transforms.wrapNodes(e,l,{split:!0}),o.Transforms.collapse(e,{edge:"end"}))},at=e=>{o.Transforms.unwrapNodes(e,{match:r=>!o.Editor.isEditor(r)&&o.Element.isElement(r)&&r.type==="link"})},ot=e=>{const[r]=o.Editor.nodes(e,{match:n=>!o.Editor.isEditor(n)&&o.Element.isElement(n)&&n.type==="link"});return!!r},xe=(e,r=3,n=3)=>{const a=Gt(r,n);o.Editor.withoutNormalizing(e,()=>{const{selection:l}=e;if(!l)return;const[u]=o.Editor.nodes(e,{match:c=>!o.Editor.isEditor(c)&&o.Element.isElement(c)&&(c.type==="heading-one"||c.type==="heading-two"||c.type==="heading-three"||c.type==="blockquote")});if(u){const[,c]=u,f=[c[0]+1];o.Transforms.insertNodes(e,a,{at:f}),o.Transforms.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:[f[0]+1]}),o.Transforms.select(e,[f[0]+1,0])}else o.Transforms.insertNodes(e,a),o.Transforms.insertNodes(e,{type:"paragraph",children:[{text:""}]})})},Gt=(e,r)=>{const n=(l=!1)=>({type:"table-cell",header:l,children:[{type:"paragraph",children:[{text:""}]}]}),a=(l=!1)=>({type:"table-row",children:Array.from({length:r},()=>n(l))});return{type:"table",children:[a(!0),...Array.from({length:e-1},()=>a(!1))]}},Qt=e=>{const[r]=o.Editor.nodes(e,{match:n=>n.type==="table"});if(r){const[,n]=r,[a]=o.Editor.nodes(e,{match:l=>l.type==="table-row"});if(a){const[l]=a,u={type:"table-row",children:l.children.map(()=>({type:"table-cell",children:[{type:"paragraph",children:[{text:""}]}]}))},c=[...n,r[0].children.length];o.Transforms.insertNodes(e,u,{at:c})}}},Zt=e=>{const[r]=o.Editor.nodes(e,{match:n=>n.type==="table"});if(r){const[n,a]=r;n.children.forEach((l,u)=>{const c={type:"table-cell",children:[{type:"paragraph",children:[{text:""}]}]},f=[...a,u,l.children.length];o.Transforms.insertNodes(e,c,{at:f})})}},er=e=>{const[r]=o.Editor.nodes(e,{match:n=>n.type==="table-row"});r&&o.Transforms.removeNodes(e,{match:n=>n.type==="table-row"})},tr=e=>{const[r]=o.Editor.nodes(e,{match:n=>n.type==="table-cell"});if(r){const[,n]=r,a=n[n.length-1],[l]=o.Editor.nodes(e,{match:u=>u.type==="table"});if(l){const[u,c]=l;for(let f=u.children.length-1;f>=0;f--){const p=[...c,f,a];o.Transforms.removeNodes(e,{at:p})}}}},rr=e=>{const[r]=o.Editor.nodes(e,{match:n=>o.Element.isElement(n)&&o.Editor.isBlock(e,n)});return r?r[0].type:"paragraph"},nr=e=>{const r=o.Editor.marks(e);return r?.["font-size-small"]?"small":r?.["font-size-large"]?"large":r?.["font-size-extra-large"]?"extra-large":"normal"},re=e=>{const[r]=o.Editor.nodes(e,{match:n=>o.Element.isElement(n)&&o.Editor.isBlock(e,n)});return r&&r[0].align?r[0].align:"left"},sr=e=>{o.Transforms.delete(e,{at:{anchor:o.Editor.start(e,[]),focus:o.Editor.end(e,[])}}),o.Transforms.select(e,o.Editor.start(e,[]))},_=({active:e,children:r,onMouseDown:n,title:a,className:l="",...u})=>s.jsx("button",{type:"button",className:`toolbar-button ${e?"active":""} ${l}`,onMouseDown:c=>{c.preventDefault(),n&&n()},title:a,...u,children:r}),Je=({value:e,onChange:r,children:n,title:a,...l})=>s.jsx("select",{className:"toolbar-select",value:e,onChange:u=>r(u.target.value),title:a,...l,children:n}),ar=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"})}),or=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"})}),lr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"})}),ir=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"})}),cr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"})}),ur=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"})}),dr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z"})}),fr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z"})}),hr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z"})}),pr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zm0-6v2h18V3H3z"})}),mr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})}),gr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"})}),vr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M10 10.02h5V21h-5zM17 21h3c1.1 0 2-.9 2-2v-9h-5v11zm3-18H5c-1.1 0-2 .9-2 2v3h19V5c0-1.1-.9-2-2-2zM3 19c0 1.1.9 2 2 2h3V10H3v9z"})}),br=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})}),xr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M2.5 4v3h5v12h3V7h5V4h-13zm19 5h-9v3h3v7h3v-7h3V9z"})}),yr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M16.56 8.94L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.59-.59 1.54 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.58.59-1.53 0-2.12zM5.21 10L10 5.21 14.79 10H5.21zM19 11.5s-2 2.17-2 3.5c0 1.1.9 2 2 2s2-.9 2-2c0-1.33-2-3.5-2-3.5z"})}),Xe=({editor:e,type:r="text"})=>{const[n,a]=k.useState(!1),[l,u]=k.useState(""),c=r==="text",f=c?et(e):tt(e),p=["#000000","#374151","#6b7280","#9ca3af","#d1d5db","#ffffff","#ef4444","#f97316","#f59e0b","#eab308","#84cc16","#22c55e","#10b981","#14b8a6","#06b6d4","#0ea5e9","#3b82f6","#6366f1","#8b5cf6","#a855f7","#d946ef","#ec4899","#f43f5e","#fb7185"],b=k.useCallback(h=>{c?se(e,h):ae(e,h),a(!1)},[e,c]),w=k.useCallback(h=>{const y=h.target.value;u(y),c?se(e,y):ae(e,y)},[e,c]),g=k.useCallback(()=>{c?se(e,null):ae(e,null),a(!1)},[e,c]);return k.useEffect(()=>{if(!n)return;const h=y=>{y.target.closest(".color-picker-dropdown")||a(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[n]),s.jsxs("div",{className:"color-picker-dropdown",children:[s.jsxs("button",{className:"toolbar-button color-picker-button",onMouseDown:h=>{h.preventDefault(),a(!n)},title:c?"Text Color":"Background Color",style:{position:"relative"},children:[c?s.jsx(xr,{}):s.jsx(yr,{}),f&&s.jsx("div",{className:"color-indicator",style:{backgroundColor:f,position:"absolute",bottom:"4px",left:"50%",transform:"translateX(-50%)",width:"20px",height:"3px",borderRadius:"2px"}})]}),n&&s.jsxs("div",{className:"color-picker-panel",children:[s.jsx("div",{className:"color-picker-presets",children:p.map(h=>s.jsx("button",{className:`color-swatch ${f===h?"active":""}`,style:{backgroundColor:h},onClick:y=>{y.stopPropagation(),b(h)},title:h},h))}),s.jsx("div",{className:"color-picker-custom",children:s.jsxs("label",{className:"color-picker-label",children:["Custom Color:",s.jsx("input",{type:"color",value:l||f||"#000000",onChange:w,className:"color-picker-input"})]})}),f&&s.jsx("button",{className:"color-picker-remove",onClick:h=>{h.stopPropagation(),g()},children:"Remove Color"})]})]})},wr=({editor:e})=>{const[r,n]=k.useState(!1),[a,l]=k.useState({row:0,col:0}),u=k.useCallback((c,f)=>{xe(e,c+1,f+1),n(!1),l({row:0,col:0})},[e]);return k.useEffect(()=>{if(!r)return;const c=f=>{f.target.closest(".table-dropdown")||n(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]),s.jsxs("div",{className:"table-dropdown",children:[s.jsx("button",{type:"button",className:"toolbar-button",onMouseDown:c=>{c.preventDefault(),n(!r)},title:"Insert Table",children:s.jsx(vr,{})}),r&&s.jsxs("div",{className:"table-size-selector",children:[s.jsx("div",{className:"table-grid",children:Array.from({length:6},(c,f)=>Array.from({length:6},(p,b)=>s.jsx("div",{className:`table-cell-selector ${f<=a.row&&b<=a.col?"active":""}`,onMouseEnter:()=>l({row:f,col:b}),onClick:w=>{w.stopPropagation(),u(f,b)}},`${f}-${b}`)))}),s.jsxs("div",{className:"table-size-label",children:[a.row+1," × ",a.col+1]})]})]})},Er=({features:e=["bold","italic","underline","strikethrough","headings","lists","alignment","fontSize","textColor","backgroundColor","link","image","table","clear"]})=>{const r=P.useSlate(),n=k.useRef(),a=c=>e.includes(c),l=c=>{const f=c.target.files[0];if(f&&f.type.startsWith("image/")){const p=new FileReader;p.onload=b=>{be(r,b.target.result)},p.readAsDataURL(f)}c.target.value=""},u=()=>{const c=window.prompt("Enter the URL:");c&&nt(r,c)};return s.jsxs("div",{className:"toolbar",children:[(a("bold")||a("italic")||a("underline")||a("strikethrough"))&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"toolbar-group",children:[a("bold")&&s.jsx(_,{active:V(r,"bold"),onMouseDown:()=>B(r,"bold"),title:"Bold (Ctrl+B)",children:s.jsx(ar,{})}),a("italic")&&s.jsx(_,{active:V(r,"italic"),onMouseDown:()=>B(r,"italic"),title:"Italic (Ctrl+I)",children:s.jsx(or,{})}),a("underline")&&s.jsx(_,{active:V(r,"underline"),onMouseDown:()=>B(r,"underline"),title:"Underline (Ctrl+U)",children:s.jsx(lr,{})}),a("strikethrough")&&s.jsx(_,{active:V(r,"strikethrough"),onMouseDown:()=>B(r,"strikethrough"),title:"Strikethrough",children:s.jsx(ir,{})})]}),s.jsx("div",{className:"toolbar-separator"})]}),a("headings")&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"toolbar-group",children:s.jsxs(Je,{value:rr(r),onChange:c=>oe(r,c),children:[s.jsx("option",{value:"paragraph",children:"Paragraph"}),s.jsx("option",{value:"heading-one",children:"Heading 1"}),s.jsx("option",{value:"heading-two",children:"Heading 2"}),s.jsx("option",{value:"heading-three",children:"Heading 3"}),s.jsx("option",{value:"blockquote",children:"Quote"})]})}),s.jsx("div",{className:"toolbar-separator"})]}),a("lists")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"toolbar-group",children:[s.jsx(_,{active:le(r,"bulleted-list"),onMouseDown:()=>oe(r,"bulleted-list"),title:"Bulleted List",children:s.jsx(cr,{})}),s.jsx(_,{active:le(r,"numbered-list"),onMouseDown:()=>oe(r,"numbered-list"),title:"Numbered List",children:s.jsx(ur,{})})]}),s.jsx("div",{className:"toolbar-separator"})]}),a("alignment")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"toolbar-group",children:[s.jsx(_,{active:re(r)==="left",onMouseDown:()=>J(r,"left"),title:"Align Left",children:s.jsx(dr,{})}),s.jsx(_,{active:re(r)==="center",onMouseDown:()=>J(r,"center"),title:"Align Center",children:s.jsx(fr,{})}),s.jsx(_,{active:re(r)==="right",onMouseDown:()=>J(r,"right"),title:"Align Right",children:s.jsx(hr,{})}),s.jsx(_,{active:re(r)==="justify",onMouseDown:()=>J(r,"justify"),title:"Justify",children:s.jsx(pr,{})})]}),s.jsx("div",{className:"toolbar-separator"})]}),a("fontSize")&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"toolbar-group",children:s.jsxs(Je,{value:nr(r),onChange:c=>B(r,`font-size-${c}`),title:"Font Size",children:[s.jsx("option",{value:"small",children:"Small"}),s.jsx("option",{value:"normal",children:"Normal"}),s.jsx("option",{value:"large",children:"Large"}),s.jsx("option",{value:"extra-large",children:"Extra Large"})]})}),s.jsx("div",{className:"toolbar-separator"})]}),(a("textColor")||a("backgroundColor"))&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"toolbar-group",children:[a("textColor")&&s.jsx(Xe,{editor:r,type:"text"}),a("backgroundColor")&&s.jsx(Xe,{editor:r,type:"background"})]}),s.jsx("div",{className:"toolbar-separator"})]}),(a("link")||a("image")||a("table"))&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"toolbar-group",children:[a("link")&&s.jsx(_,{onMouseDown:u,title:"Insert Link",children:s.jsx(mr,{})}),a("image")&&s.jsx(_,{onMouseDown:()=>n.current?.click(),title:"Insert Image",children:s.jsx(gr,{})}),a("table")&&s.jsx(wr,{editor:r})]}),s.jsx("div",{className:"toolbar-separator"})]}),a("clear")&&s.jsx("div",{className:"toolbar-group",children:s.jsx(_,{onMouseDown:()=>sr(r),title:"Clear All Content",className:"clear-button",children:s.jsx(br,{})})}),s.jsx("input",{ref:n,type:"file",accept:"image/*",onChange:l,style:{display:"none"}})]})},kr=({attributes:e,children:r,element:n,editor:a})=>{const l=P.useSelected(),u=P.useFocused(),[c,f]=k.useState(!1),p=k.useRef(),b=k.useCallback(h=>{h.preventDefault(),h.stopPropagation(),f(!0);const y=h.clientX,D=p.current.offsetWidth;p.current.naturalHeight/p.current.naturalWidth;const $=N=>{const C=N.clientX-y,ie=Math.max(100,Math.min(1200,D+C));p.current.style.width=`${ie}px`,p.current.style.height="auto"},I=()=>{f(!1);const N=p.current.offsetWidth;try{const C=P.ReactEditor.findPath(a,n);o.Transforms.setNodes(a,{width:N,height:"auto"},{at:C})}catch(C){console.warn("Could not update image dimensions:",C)}document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",I)};document.addEventListener("mousemove",$),document.addEventListener("mouseup",I)},[a,n]),w=k.useCallback(h=>{h.preventDefault(),h.stopPropagation();try{const y=P.ReactEditor.findPath(a,n);o.Transforms.removeNodes(a,{at:y})}catch(y){console.warn("Could not delete image:",y)}},[a,n]),g=n.width||300;return s.jsxs("div",{...e,children:[r,s.jsx("div",{contentEditable:!1,className:`image-container ${l&&u?"selected":""}`,style:{display:"block",position:"relative",margin:"16px 0",textAlign:"center"},children:s.jsxs("div",{style:{display:"inline-block",position:"relative"},children:[s.jsx("img",{ref:p,src:n.url,alt:n.alt||"",className:"resizable-image",style:{width:`${g}px`,height:"auto",maxWidth:"100%",display:"block",borderRadius:"4px",boxShadow:l&&u?"0 0 0 3px #3b82f6":"0 1px 3px rgba(0, 0, 0, 0.1)",transition:c?"none":"box-shadow 0.15s ease",userSelect:"none"},draggable:!1}),l&&u&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"resize-handle",onMouseDown:b,style:{position:"absolute",bottom:"-6px",right:"-6px",width:"16px",height:"16px",background:"#3b82f6",border:"2px solid white",cursor:"nwse-resize",borderRadius:"50%",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.3)",zIndex:10}}),s.jsx("button",{className:"delete-button",onMouseDown:w,title:"Delete image",type:"button",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",background:"#ef4444",color:"white",border:"none",borderRadius:"50%",cursor:"pointer",fontSize:"18px",fontWeight:"bold",lineHeight:"1",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.3)",zIndex:11,padding:0},children:"×"})]})]})})]})},jr=({attributes:e,children:r,element:n})=>{const a={textAlign:n.align};switch(n.type){case"heading-one":return s.jsx("h1",{...e,style:a,className:"heading-one",children:r});case"heading-two":return s.jsx("h2",{...e,style:a,className:"heading-two",children:r});case"heading-three":return s.jsx("h3",{...e,style:a,className:"heading-three",children:r});case"blockquote":return s.jsx("blockquote",{...e,style:a,className:"blockquote",children:r});case"bulleted-list":return s.jsx("ul",{...e,style:a,className:"bulleted-list",children:r});case"numbered-list":return s.jsx("ol",{...e,style:a,className:"numbered-list",children:r});case"list-item":return s.jsx("li",{...e,className:"list-item",children:r});case"link":return s.jsx("a",{...e,href:n.url,className:"link",children:r});case"image":return s.jsx(kr,{attributes:e,children:r,element:n,editor:P.useSlate()});case"table":return s.jsx("div",{...e,className:"table-container",children:s.jsx("table",{className:"simple-table",children:s.jsx("tbody",{children:r})})});case"table-row":return s.jsx("tr",{...e,className:"table-row",children:r});case"table-cell":return s.jsx("td",{...e,className:`table-cell ${n.header?"table-header-cell":""}`,children:r});default:return s.jsx("p",{...e,style:a,className:"paragraph",children:r})}},Cr=({attributes:e,children:r,leaf:n})=>{let a="",l={};return n.bold&&(a+=" bold"),n.italic&&(a+=" italic"),n.underline&&(a+=" underline"),n.strikethrough&&(a+=" strikethrough"),n["font-size-small"]&&(a+=" font-size-small"),n["font-size-large"]&&(a+=" font-size-large"),n["font-size-extra-large"]&&(a+=" font-size-extra-large"),n.color&&(l.color=n.color),n.backgroundColor&&(l.backgroundColor=n.backgroundColor),s.jsx("span",{...e,className:a.trim(),style:l,children:r})},Rr=({target:e,search:r,onClose:n})=>{const a=P.useSlate(),l=k.useRef(),[u,c]=k.useState(0),p=[{title:"Heading 1",description:"Big section heading",icon:"H1",command:()=>b(a,"heading-one")},{title:"Heading 2",description:"Medium section heading",icon:"H2",command:()=>b(a,"heading-two")},{title:"Heading 3",description:"Small section heading",icon:"H3",command:()=>b(a,"heading-three")},{title:"Bulleted List",description:"Create a simple bulleted list",icon:"•",command:()=>b(a,"bulleted-list")},{title:"Numbered List",description:"Create a list with numbering",icon:"1.",command:()=>b(a,"numbered-list")},{title:"Quote",description:"Capture a quote",icon:'"',command:()=>b(a,"blockquote")},{title:"Table",description:"Insert a table",icon:"⊞",command:()=>{w(a,e),xe(a,3,3),n()}},{title:"Image",description:"Upload or embed an image",icon:"🖼",command:()=>{w(a,e);const g=document.createElement("input");g.type="file",g.accept="image/*",g.onchange=h=>{const y=h.target.files[0];if(y){const D=new FileReader;D.onload=$=>{be(a,$.target.result)},D.readAsDataURL(y)}},g.click(),n()}}].filter(g=>g.title.toLowerCase().includes(r.toLowerCase())||g.description.toLowerCase().includes(r.toLowerCase())),b=(g,h)=>{w(g,e);const y={type:h};h==="bulleted-list"||h==="numbered-list"?(o.Transforms.setNodes(g,{type:"list-item"}),o.Transforms.wrapNodes(g,{type:h,children:[]})):o.Transforms.setNodes(g,y),n()},w=(g,h)=>{o.Transforms.select(g,h),o.Transforms.delete(g)};return k.useEffect(()=>{c(0)},[r]),k.useEffect(()=>{const g=h=>{h.key==="ArrowDown"?(h.preventDefault(),c(y=>y<p.length-1?y+1:0)):h.key==="ArrowUp"?(h.preventDefault(),c(y=>y>0?y-1:p.length-1)):h.key==="Enter"?(h.preventDefault(),p[u]&&p[u].command()):h.key==="Escape"&&(h.preventDefault(),n())};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[u,p,n]),p.length===0?null:s.jsx("div",{ref:l,className:"slash-menu",children:p.map((g,h)=>s.jsxs("div",{className:`slash-menu-item ${h===u?"selected":""}`,onClick:g.command,children:[s.jsx("div",{className:"slash-menu-icon",children:g.icon}),s.jsxs("div",{className:"slash-menu-content",children:[s.jsx("div",{className:"slash-menu-title",children:g.title}),s.jsx("div",{className:"slash-menu-description",children:g.description})]})]},g.title))})},Tr=e=>{const{insertData:r,isVoid:n}=e;return e.isVoid=a=>a.type==="image"?!0:n(a),e.insertData=a=>{const l=a.getData("text/plain"),{files:u}=a;if(u&&u.length>0)for(const c of u){const f=new FileReader,[p]=c.type.split("/");p==="image"&&(f.addEventListener("load",()=>{const b=f.result;Ge(e,b)}),f.readAsDataURL(c))}else rt(l)?Ge(e,l):r(a)},e},Ge=(e,r)=>{const a={type:"image",url:r,children:[{text:""}]};o.Transforms.insertNodes(e,a)},Nr=e=>{const{deleteBackward:r,deleteForward:n,insertBreak:a}=e;return e.deleteBackward=(...l)=>{const{selection:u}=e;if(u&&o.Range.isCollapsed(u)){const[c]=o.Editor.nodes(e,{match:f=>f.type==="table-cell"});if(c){const[,f]=c,p=o.Editor.start(e,f);if(o.Point.equals(u.anchor,p))return}}r(...l)},e.deleteForward=(...l)=>{const{selection:u}=e;if(u&&o.Range.isCollapsed(u)){const[c]=o.Editor.nodes(e,{match:f=>f.type==="table-cell"});if(c){const[,f]=c,p=o.Editor.end(e,f);if(o.Point.equals(u.anchor,p))return}}n(...l)},e.insertBreak=(...l)=>{const{selection:u}=e;if(u){const[c]=o.Editor.nodes(e,{match:f=>f.type==="table"});if(c)return}a(...l)},e},zr=e=>{const{insertData:r,insertText:n,isInline:a}=e;return e.isInline=l=>l.type==="link"?!0:a(l),e.insertText=l=>{l&&Qe(l)?Ze(e,l):n(l)},e.insertData=l=>{const u=l.getData("text/plain");u&&Qe(u)?Ze(e,u):r(l)},e},Qe=e=>{try{return new URL(e),!0}catch{return!1}},Ze=(e,r)=>{_r(e)&&Mr(e);const{selection:n}=e,a=n&&o.Range.isCollapsed(n),l={type:"link",url:r,children:a?[{text:r}]:[]};a?o.Transforms.insertNodes(e,l):(o.Transforms.wrapNodes(e,l,{split:!0}),o.Transforms.collapse(e,{edge:"end"}))},Mr=e=>{o.Transforms.unwrapNodes(e,{match:r=>r.type==="link"})},_r=e=>{const[r]=o.Editor.nodes(e,{match:n=>n.type==="link"});return!!r},lt=e=>e.map(r=>it(r)).join(""),it=e=>{if(o.Text.isText(e)){let n=ee(e.text);return e.bold&&(n=`<strong>${n}</strong>`),e.italic&&(n=`<em>${n}</em>`),e.underline&&(n=`<u>${n}</u>`),e.strikethrough&&(n=`<s>${n}</s>`),e["font-size-small"]?n=`<span style="font-size: 12px;">${n}</span>`:e["font-size-large"]?n=`<span style="font-size: 16px;">${n}</span>`:e["font-size-extra-large"]&&(n=`<span style="font-size: 18px;">${n}</span>`),e.color&&(n=`<span style="color: ${e.color};">${n}</span>`),e.backgroundColor&&(n=`<span style="background-color: ${e.backgroundColor};">${n}</span>`),n}const r=e.children.map(n=>it(n)).join("");switch(e.type){case"paragraph":return`<p${K(e)}>${r}</p>`;case"heading-one":return`<h1${K(e)}>${r}</h1>`;case"heading-two":return`<h2${K(e)}>${r}</h2>`;case"heading-three":return`<h3${K(e)}>${r}</h3>`;case"blockquote":return`<blockquote${K(e)}>${r}</blockquote>`;case"bulleted-list":return`<ul>${r}</ul>`;case"numbered-list":return`<ol>${r}</ol>`;case"list-item":return`<li>${r}</li>`;case"link":return`<a href="${ee(e.url)}">${r}</a>`;case"image":const n=e.width?`width: ${e.width}px; `:"";return`<img src="${ee(e.url)}" alt="${ee(e.alt||"")}" style="${n}max-width: 100%; height: auto;" />`;case"table":return`<table border="1" style="border-collapse: collapse; width: 100%;">${r}</table>`;case"table-row":return`<tr>${r}</tr>`;case"table-cell":const a=e.header?"th":"td";return`<${a} style="border: 1px solid #ccc; padding: 8px;">${r}</${a}>`;default:return r}},K=e=>e.align?` style="text-align: ${e.align};"`:"",ct=e=>{const r=new DOMParser().parseFromString(e,"text/html");return ut(r.body.childNodes)},ut=e=>{const r=[];for(const n of e){const a=Sr(n);a&&(Array.isArray(a)?r.push(...a):r.push(a))}return r.length>0?r:[{type:"paragraph",children:[{text:""}]}]},Sr=e=>{if(e.nodeType===Node.TEXT_NODE)return{text:e.textContent};if(e.nodeType!==Node.ELEMENT_NODE)return null;const r=ut(e.childNodes),n={children:r},a=e.getAttribute("style");if(a&&a.includes("text-align:")){const l=a.match(/text-align:\s*([^;]+)/);l&&(n.align=l[1].trim())}switch(e.nodeName.toLowerCase()){case"p":return{...n,type:"paragraph"};case"h1":return{...n,type:"heading-one"};case"h2":return{...n,type:"heading-two"};case"h3":return{...n,type:"heading-three"};case"blockquote":return{...n,type:"blockquote"};case"ul":return{...n,type:"bulleted-list"};case"ol":return{...n,type:"numbered-list"};case"li":return{...n,type:"list-item"};case"a":return{...n,type:"link",url:e.getAttribute("href")};case"img":const l=e.getAttribute("style");let u=300;if(l&&l.includes("width:")){const c=l.match(/width:\s*(\d+)px/);c&&(u=parseInt(c[1]))}return{type:"image",url:e.getAttribute("src"),alt:e.getAttribute("alt")||"",width:u,children:[{text:""}]};case"table":return{...n,type:"table"};case"tr":return{...n,type:"table-row"};case"td":return{...n,type:"table-cell"};case"th":return{...n,type:"table-cell",header:!0};case"strong":case"b":return ne(r,"bold");case"em":case"i":return ne(r,"italic");case"u":return ne(r,"underline");case"s":case"strike":return ne(r,"strikethrough");case"span":return Dr(e,r);case"br":return{text:`
|
|
15
|
-
`};case"div":return r.length>0?{...n,type:"paragraph"}:null;default:return r}},ne=(e,r)=>e.map(n=>n.text!==void 0?{...n,[r]:!0}:n),Dr=(e,r)=>{const n=e.getAttribute("style");let a={};if(n){n.includes("font-size: 12px")?a["font-size-small"]=!0:n.includes("font-size: 16px")?a["font-size-large"]=!0:n.includes("font-size: 18px")&&(a["font-size-extra-large"]=!0);const
|
|
14
|
+
<%s key={someKey} {...props} />`,ge,O,Ut,O),Ve[O+ge]=!0}}return t===a?Ot(T):At(T),T}}function Ht(t,i,f){return Ue(t,i,f,!0)}function Ft(t,i,f){return Ue(t,i,f,!1)}var Bt=Ft,Vt=Ht;Y.Fragment=a,Y.jsx=Bt,Y.jsxs=Vt})()),Y}var Ye;function Jt(){return Ye||(Ye=1,process.env.NODE_ENV==="production"?te.exports=Yt():te.exports=Kt()),te.exports}var s=Jt();const B=(e,r)=>{const n=V(e,r);if(r.startsWith("font-size-")){l.Editor.removeMark(e,"font-size-small"),l.Editor.removeMark(e,"font-size-normal"),l.Editor.removeMark(e,"font-size-large"),l.Editor.removeMark(e,"font-size-extra-large"),n||l.Editor.addMark(e,r,!0);return}n?l.Editor.removeMark(e,r):l.Editor.addMark(e,r,!0)},V=(e,r)=>{const n=l.Editor.marks(e);return n?n[r]===!0:!1},se=(e,r)=>{r?l.Editor.addMark(e,"color",r):l.Editor.removeMark(e,"color")},et=e=>l.Editor.marks(e)?.color||null,ae=(e,r)=>{r?l.Editor.addMark(e,"backgroundColor",r):l.Editor.removeMark(e,"backgroundColor")},tt=e=>l.Editor.marks(e)?.backgroundColor||null,oe=(e,r)=>{const n=le(e,r),a=Ke.includes(r);l.Transforms.unwrapNodes(e,{match:d=>!l.Editor.isEditor(d)&&l.Element.isElement(d)&&Ke.includes(d.type),split:!0});let o;if(n?o={type:"paragraph"}:a?o={type:"list-item"}:o={type:r},l.Transforms.setNodes(e,o),!n&&a){const d={type:r,children:[]};l.Transforms.wrapNodes(e,d)}},J=(e,r)=>{l.Transforms.setNodes(e,{align:r},{match:n=>l.Element.isElement(n)&&l.Editor.isBlock(e,n),split:!0})},le=(e,r,n="type")=>{const{selection:a}=e;if(!a)return!1;const[o]=Array.from(l.Editor.nodes(e,{at:l.Editor.unhangRange(e,a),match:d=>!l.Editor.isEditor(d)&&l.Element.isElement(d)&&d[n]===r}));return!!o},Ke=["numbered-list","bulleted-list"],be=(e,r,n="")=>{const o={type:"image",url:r,alt:n,width:"auto",height:"auto",children:[{text:""}]};l.Transforms.insertNodes(e,o),l.Transforms.insertNodes(e,{type:"paragraph",children:[{text:""}]})},rt=e=>{if(!e||!Xt(e))return!1;const r=new URL(e).pathname.split(".").pop();return["jpg","jpeg","png","gif","webp","svg"].includes(r.toLowerCase())},Xt=e=>{try{return new URL(e),!0}catch{return!1}},nt=(e,r)=>{e.selection&&st(e,r)},st=(e,r)=>{ot(e)&&at(e);const{selection:n}=e,a=n&&l.Range.isCollapsed(n),o={type:"link",url:r,children:a?[{text:r}]:[]};a?l.Transforms.insertNodes(e,o):(l.Transforms.wrapNodes(e,o,{split:!0}),l.Transforms.collapse(e,{edge:"end"}))},at=e=>{l.Transforms.unwrapNodes(e,{match:r=>!l.Editor.isEditor(r)&&l.Element.isElement(r)&&r.type==="link"})},ot=e=>{const[r]=l.Editor.nodes(e,{match:n=>!l.Editor.isEditor(n)&&l.Element.isElement(n)&&n.type==="link"});return!!r},xe=(e,r=3,n=3)=>{const a=Gt(r,n);l.Editor.withoutNormalizing(e,()=>{const{selection:o}=e;if(!o)return;const[d]=l.Editor.nodes(e,{match:c=>!l.Editor.isEditor(c)&&l.Element.isElement(c)&&(c.type==="heading-one"||c.type==="heading-two"||c.type==="heading-three"||c.type==="blockquote")});if(d){const[,c]=d,u=[c[0]+1];l.Transforms.insertNodes(e,a,{at:u}),l.Transforms.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:[u[0]+1]}),l.Transforms.select(e,[u[0]+1,0])}else l.Transforms.insertNodes(e,a),l.Transforms.insertNodes(e,{type:"paragraph",children:[{text:""}]})})},Gt=(e,r)=>{const n=(o=!1)=>({type:"table-cell",header:o,children:[{type:"paragraph",children:[{text:""}]}]}),a=(o=!1)=>({type:"table-row",children:Array.from({length:r},()=>n(o))});return{type:"table",children:[a(!0),...Array.from({length:e-1},()=>a(!1))]}},Qt=e=>{const[r]=l.Editor.nodes(e,{match:n=>n.type==="table"});if(r){const[,n]=r,[a]=l.Editor.nodes(e,{match:o=>o.type==="table-row"});if(a){const[o]=a,d={type:"table-row",children:o.children.map(()=>({type:"table-cell",children:[{type:"paragraph",children:[{text:""}]}]}))},c=[...n,r[0].children.length];l.Transforms.insertNodes(e,d,{at:c})}}},Zt=e=>{const[r]=l.Editor.nodes(e,{match:n=>n.type==="table"});if(r){const[n,a]=r;n.children.forEach((o,d)=>{const c={type:"table-cell",children:[{type:"paragraph",children:[{text:""}]}]},u=[...a,d,o.children.length];l.Transforms.insertNodes(e,c,{at:u})})}},er=e=>{const[r]=l.Editor.nodes(e,{match:n=>n.type==="table-row"});r&&l.Transforms.removeNodes(e,{match:n=>n.type==="table-row"})},tr=e=>{const[r]=l.Editor.nodes(e,{match:n=>n.type==="table-cell"});if(r){const[,n]=r,a=n[n.length-1],[o]=l.Editor.nodes(e,{match:d=>d.type==="table"});if(o){const[d,c]=o;for(let u=d.children.length-1;u>=0;u--){const p=[...c,u,a];l.Transforms.removeNodes(e,{at:p})}}}},rr=e=>{const[r]=l.Editor.nodes(e,{match:n=>l.Element.isElement(n)&&l.Editor.isBlock(e,n)});return r?r[0].type:"paragraph"},nr=e=>{const r=l.Editor.marks(e);return r?.["font-size-small"]?"small":r?.["font-size-large"]?"large":r?.["font-size-extra-large"]?"extra-large":"normal"},re=e=>{const[r]=l.Editor.nodes(e,{match:n=>l.Element.isElement(n)&&l.Editor.isBlock(e,n)});return r&&r[0].align?r[0].align:"left"},sr=e=>{l.Transforms.delete(e,{at:{anchor:l.Editor.start(e,[]),focus:l.Editor.end(e,[])}}),l.Transforms.select(e,l.Editor.start(e,[]))},S=({active:e,children:r,onMouseDown:n,title:a,className:o="",...d})=>s.jsx("button",{type:"button",className:`toolbar-button ${e?"active":""} ${o}`,onMouseDown:c=>{c.preventDefault(),n&&n()},title:a,...d,children:r}),Je=({value:e,onChange:r,children:n,title:a,...o})=>s.jsx("select",{className:"toolbar-select",value:e,onChange:d=>r(d.target.value),title:a,...o,children:n}),ar=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"})}),or=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"})}),lr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"})}),ir=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"})}),cr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"})}),ur=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"})}),dr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z"})}),fr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z"})}),hr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z"})}),pr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zm0-6v2h18V3H3z"})}),mr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})}),gr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"})}),vr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M10 10.02h5V21h-5zM17 21h3c1.1 0 2-.9 2-2v-9h-5v11zm3-18H5c-1.1 0-2 .9-2 2v3h19V5c0-1.1-.9-2-2-2zM3 19c0 1.1.9 2 2 2h3V10H3v9z"})}),br=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})}),xr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M2.5 4v3h5v12h3V7h5V4h-13zm19 5h-9v3h3v7h3v-7h3V9z"})}),yr=()=>s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M16.56 8.94L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.59-.59 1.54 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.58.59-1.53 0-2.12zM5.21 10L10 5.21 14.79 10H5.21zM19 11.5s-2 2.17-2 3.5c0 1.1.9 2 2 2s2-.9 2-2c0-1.33-2-3.5-2-3.5z"})}),Xe=({editor:e,type:r="text"})=>{const[n,a]=w.useState(!1),[o,d]=w.useState(""),c=r==="text",u=c?et(e):tt(e),p=["#000000","#374151","#6b7280","#9ca3af","#d1d5db","#ffffff","#ef4444","#f97316","#f59e0b","#eab308","#84cc16","#22c55e","#10b981","#14b8a6","#06b6d4","#0ea5e9","#3b82f6","#6366f1","#8b5cf6","#a855f7","#d946ef","#ec4899","#f43f5e","#fb7185"],b=w.useCallback(h=>{c?se(e,h):ae(e,h),a(!1)},[e,c]),y=w.useCallback(h=>{const E=h.target.value;d(E),c?se(e,E):ae(e,E)},[e,c]),g=w.useCallback(()=>{c?se(e,null):ae(e,null),a(!1)},[e,c]);return w.useEffect(()=>{if(!n)return;const h=E=>{E.target.closest(".color-picker-dropdown")||a(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[n]),s.jsxs("div",{className:"color-picker-dropdown",children:[s.jsxs("button",{className:"toolbar-button color-picker-button",onMouseDown:h=>{h.preventDefault(),a(!n)},title:c?"Text Color":"Background Color",style:{position:"relative"},children:[c?s.jsx(xr,{}):s.jsx(yr,{}),u&&s.jsx("div",{className:"color-indicator",style:{backgroundColor:u,position:"absolute",bottom:"4px",left:"50%",transform:"translateX(-50%)",width:"20px",height:"3px",borderRadius:"2px"}})]}),n&&s.jsxs("div",{className:"color-picker-panel",children:[s.jsx("div",{className:"color-picker-presets",children:p.map(h=>s.jsx("button",{className:`color-swatch ${u===h?"active":""}`,style:{backgroundColor:h},onClick:E=>{E.stopPropagation(),b(h)},title:h},h))}),s.jsx("div",{className:"color-picker-custom",children:s.jsxs("label",{className:"color-picker-label",children:["Custom Color:",s.jsx("input",{type:"color",value:o||u||"#000000",onChange:y,className:"color-picker-input"})]})}),u&&s.jsx("button",{className:"color-picker-remove",onClick:h=>{h.stopPropagation(),g()},children:"Remove Color"})]})]})},Er=({editor:e})=>{const[r,n]=w.useState(!1),[a,o]=w.useState({row:0,col:0}),d=w.useCallback((c,u)=>{xe(e,c+1,u+1),n(!1),o({row:0,col:0})},[e]);return w.useEffect(()=>{if(!r)return;const c=u=>{u.target.closest(".table-dropdown")||n(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]),s.jsxs("div",{className:"table-dropdown",children:[s.jsx("button",{type:"button",className:"toolbar-button",onMouseDown:c=>{c.preventDefault(),n(!r)},title:"Insert Table",children:s.jsx(vr,{})}),r&&s.jsxs("div",{className:"table-size-selector",children:[s.jsx("div",{className:"table-grid",children:Array.from({length:6},(c,u)=>Array.from({length:6},(p,b)=>s.jsx("div",{className:`table-cell-selector ${u<=a.row&&b<=a.col?"active":""}`,onMouseEnter:()=>o({row:u,col:b}),onClick:y=>{y.stopPropagation(),d(u,b)}},`${u}-${b}`)))}),s.jsxs("div",{className:"table-size-label",children:[a.row+1," × ",a.col+1]})]})]})},wr=({features:e=["bold","italic","underline","strikethrough","headings","lists","alignment","fontSize","textColor","backgroundColor","link","image","table","clear"]})=>{const r=P.useSlate(),n=w.useRef(),[,a]=w.useState(0);w.useEffect(()=>{const u=()=>{a(p=>p+1)};return document.addEventListener("selectionchange",u),()=>document.removeEventListener("selectionchange",u)},[]);const o=u=>e.includes(u),d=u=>{const p=u.target.files[0];if(p&&p.type.startsWith("image/")){const b=new FileReader;b.onload=y=>{be(r,y.target.result)},b.readAsDataURL(p)}u.target.value=""},c=()=>{const u=window.prompt("Enter the URL:");u&&nt(r,u)};return s.jsxs("div",{className:"toolbar",children:[(o("bold")||o("italic")||o("underline")||o("strikethrough"))&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"toolbar-group",children:[o("bold")&&s.jsx(S,{active:V(r,"bold"),onMouseDown:()=>B(r,"bold"),title:"Bold (Ctrl+B)",children:s.jsx(ar,{})}),o("italic")&&s.jsx(S,{active:V(r,"italic"),onMouseDown:()=>B(r,"italic"),title:"Italic (Ctrl+I)",children:s.jsx(or,{})}),o("underline")&&s.jsx(S,{active:V(r,"underline"),onMouseDown:()=>B(r,"underline"),title:"Underline (Ctrl+U)",children:s.jsx(lr,{})}),o("strikethrough")&&s.jsx(S,{active:V(r,"strikethrough"),onMouseDown:()=>B(r,"strikethrough"),title:"Strikethrough",children:s.jsx(ir,{})})]}),s.jsx("div",{className:"toolbar-separator"})]}),o("headings")&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"toolbar-group",children:s.jsxs(Je,{value:rr(r),onChange:u=>oe(r,u),children:[s.jsx("option",{value:"paragraph",children:"Paragraph"}),s.jsx("option",{value:"heading-one",children:"Heading 1"}),s.jsx("option",{value:"heading-two",children:"Heading 2"}),s.jsx("option",{value:"heading-three",children:"Heading 3"}),s.jsx("option",{value:"blockquote",children:"Quote"})]})}),s.jsx("div",{className:"toolbar-separator"})]}),o("lists")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"toolbar-group",children:[s.jsx(S,{active:le(r,"bulleted-list"),onMouseDown:()=>oe(r,"bulleted-list"),title:"Bulleted List",children:s.jsx(cr,{})}),s.jsx(S,{active:le(r,"numbered-list"),onMouseDown:()=>oe(r,"numbered-list"),title:"Numbered List",children:s.jsx(ur,{})})]}),s.jsx("div",{className:"toolbar-separator"})]}),o("alignment")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"toolbar-group",children:[s.jsx(S,{active:re(r)==="left",onMouseDown:()=>J(r,"left"),title:"Align Left",children:s.jsx(dr,{})}),s.jsx(S,{active:re(r)==="center",onMouseDown:()=>J(r,"center"),title:"Align Center",children:s.jsx(fr,{})}),s.jsx(S,{active:re(r)==="right",onMouseDown:()=>J(r,"right"),title:"Align Right",children:s.jsx(hr,{})}),s.jsx(S,{active:re(r)==="justify",onMouseDown:()=>J(r,"justify"),title:"Justify",children:s.jsx(pr,{})})]}),s.jsx("div",{className:"toolbar-separator"})]}),o("fontSize")&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"toolbar-group",children:s.jsxs(Je,{value:nr(r),onChange:u=>B(r,`font-size-${u}`),title:"Font Size",children:[s.jsx("option",{value:"small",children:"Small"}),s.jsx("option",{value:"normal",children:"Normal"}),s.jsx("option",{value:"large",children:"Large"}),s.jsx("option",{value:"extra-large",children:"Extra Large"})]})}),s.jsx("div",{className:"toolbar-separator"})]}),(o("textColor")||o("backgroundColor"))&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"toolbar-group",children:[o("textColor")&&s.jsx(Xe,{editor:r,type:"text"}),o("backgroundColor")&&s.jsx(Xe,{editor:r,type:"background"})]}),s.jsx("div",{className:"toolbar-separator"})]}),(o("link")||o("image")||o("table"))&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"toolbar-group",children:[o("link")&&s.jsx(S,{onMouseDown:c,title:"Insert Link",children:s.jsx(mr,{})}),o("image")&&s.jsx(S,{onMouseDown:()=>n.current?.click(),title:"Insert Image",children:s.jsx(gr,{})}),o("table")&&s.jsx(Er,{editor:r})]}),s.jsx("div",{className:"toolbar-separator"})]}),o("clear")&&s.jsx("div",{className:"toolbar-group",children:s.jsx(S,{onMouseDown:()=>sr(r),title:"Clear All Content",className:"clear-button",children:s.jsx(br,{})})}),s.jsx("input",{ref:n,type:"file",accept:"image/*",onChange:d,style:{display:"none"}})]})},kr=({attributes:e,children:r,element:n,editor:a})=>{const o=P.useSelected(),d=P.useFocused(),[c,u]=w.useState(!1),p=w.useRef(),b=w.useCallback(h=>{h.preventDefault(),h.stopPropagation(),u(!0);const E=h.clientX,D=p.current.offsetWidth;p.current.naturalHeight/p.current.naturalWidth;const $=N=>{const C=N.clientX-E,ie=Math.max(100,Math.min(1200,D+C));p.current.style.width=`${ie}px`,p.current.style.height="auto"},I=()=>{u(!1);const N=p.current.offsetWidth;try{const C=P.ReactEditor.findPath(a,n);l.Transforms.setNodes(a,{width:N,height:"auto"},{at:C})}catch(C){console.warn("Could not update image dimensions:",C)}document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",I)};document.addEventListener("mousemove",$),document.addEventListener("mouseup",I)},[a,n]),y=w.useCallback(h=>{h.preventDefault(),h.stopPropagation();try{const E=P.ReactEditor.findPath(a,n);l.Transforms.removeNodes(a,{at:E})}catch(E){console.warn("Could not delete image:",E)}},[a,n]),g=n.width||300;return s.jsxs("div",{...e,children:[r,s.jsx("div",{contentEditable:!1,className:`image-container ${o&&d?"selected":""}`,style:{display:"block",position:"relative",margin:"16px 0",textAlign:"center"},children:s.jsxs("div",{style:{display:"inline-block",position:"relative"},children:[s.jsx("img",{ref:p,src:n.url,alt:n.alt||"",className:"resizable-image",style:{width:`${g}px`,height:"auto",maxWidth:"100%",display:"block",borderRadius:"4px",boxShadow:o&&d?"0 0 0 3px #3b82f6":"0 1px 3px rgba(0, 0, 0, 0.1)",transition:c?"none":"box-shadow 0.15s ease",userSelect:"none"},draggable:!1}),o&&d&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"resize-handle",onMouseDown:b,style:{position:"absolute",bottom:"-6px",right:"-6px",width:"16px",height:"16px",background:"#3b82f6",border:"2px solid white",cursor:"nwse-resize",borderRadius:"50%",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.3)",zIndex:10}}),s.jsx("button",{className:"delete-button",onMouseDown:y,title:"Delete image",type:"button",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",background:"#ef4444",color:"white",border:"none",borderRadius:"50%",cursor:"pointer",fontSize:"18px",fontWeight:"bold",lineHeight:"1",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.3)",zIndex:11,padding:0},children:"×"})]})]})})]})},jr=({attributes:e,children:r,element:n})=>{const a={textAlign:n.align};switch(n.type){case"heading-one":return s.jsx("h1",{...e,style:a,className:"heading-one",children:r});case"heading-two":return s.jsx("h2",{...e,style:a,className:"heading-two",children:r});case"heading-three":return s.jsx("h3",{...e,style:a,className:"heading-three",children:r});case"blockquote":return s.jsx("blockquote",{...e,style:a,className:"blockquote",children:r});case"bulleted-list":return s.jsx("ul",{...e,style:a,className:"bulleted-list",children:r});case"numbered-list":return s.jsx("ol",{...e,style:a,className:"numbered-list",children:r});case"list-item":return s.jsx("li",{...e,className:"list-item",children:r});case"link":return s.jsx("a",{...e,href:n.url,className:"link",children:r});case"image":return s.jsx(kr,{attributes:e,children:r,element:n,editor:P.useSlate()});case"table":return s.jsx("div",{...e,className:"table-container",children:s.jsx("table",{className:"simple-table",children:s.jsx("tbody",{children:r})})});case"table-row":return s.jsx("tr",{...e,className:"table-row",children:r});case"table-cell":return s.jsx("td",{...e,className:`table-cell ${n.header?"table-header-cell":""}`,children:r});default:return s.jsx("p",{...e,style:a,className:"paragraph",children:r})}},Cr=({attributes:e,children:r,leaf:n})=>{let a="",o={};return n.bold&&(a+=" bold"),n.italic&&(a+=" italic"),n.underline&&(a+=" underline"),n.strikethrough&&(a+=" strikethrough"),n["font-size-small"]&&(a+=" font-size-small"),n["font-size-large"]&&(a+=" font-size-large"),n["font-size-extra-large"]&&(a+=" font-size-extra-large"),n.color&&(o.color=n.color),n.backgroundColor&&(o.backgroundColor=n.backgroundColor),s.jsx("span",{...e,className:a.trim(),style:o,children:r})},Rr=({target:e,search:r,onClose:n})=>{const a=P.useSlate(),o=w.useRef(),[d,c]=w.useState(0),p=[{title:"Heading 1",description:"Big section heading",icon:"H1",command:()=>b(a,"heading-one")},{title:"Heading 2",description:"Medium section heading",icon:"H2",command:()=>b(a,"heading-two")},{title:"Heading 3",description:"Small section heading",icon:"H3",command:()=>b(a,"heading-three")},{title:"Bulleted List",description:"Create a simple bulleted list",icon:"•",command:()=>b(a,"bulleted-list")},{title:"Numbered List",description:"Create a list with numbering",icon:"1.",command:()=>b(a,"numbered-list")},{title:"Quote",description:"Capture a quote",icon:'"',command:()=>b(a,"blockquote")},{title:"Table",description:"Insert a table",icon:"⊞",command:()=>{y(a,e),xe(a,3,3),n()}},{title:"Image",description:"Upload or embed an image",icon:"🖼",command:()=>{y(a,e);const g=document.createElement("input");g.type="file",g.accept="image/*",g.onchange=h=>{const E=h.target.files[0];if(E){const D=new FileReader;D.onload=$=>{be(a,$.target.result)},D.readAsDataURL(E)}},g.click(),n()}}].filter(g=>g.title.toLowerCase().includes(r.toLowerCase())||g.description.toLowerCase().includes(r.toLowerCase())),b=(g,h)=>{y(g,e);const E={type:h};h==="bulleted-list"||h==="numbered-list"?(l.Transforms.setNodes(g,{type:"list-item"}),l.Transforms.wrapNodes(g,{type:h,children:[]})):l.Transforms.setNodes(g,E),n()},y=(g,h)=>{l.Transforms.select(g,h),l.Transforms.delete(g)};return w.useEffect(()=>{c(0)},[r]),w.useEffect(()=>{const g=h=>{h.key==="ArrowDown"?(h.preventDefault(),c(E=>E<p.length-1?E+1:0)):h.key==="ArrowUp"?(h.preventDefault(),c(E=>E>0?E-1:p.length-1)):h.key==="Enter"?(h.preventDefault(),p[d]&&p[d].command()):h.key==="Escape"&&(h.preventDefault(),n())};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[d,p,n]),p.length===0?null:s.jsx("div",{ref:o,className:"slash-menu",children:p.map((g,h)=>s.jsxs("div",{className:`slash-menu-item ${h===d?"selected":""}`,onClick:g.command,children:[s.jsx("div",{className:"slash-menu-icon",children:g.icon}),s.jsxs("div",{className:"slash-menu-content",children:[s.jsx("div",{className:"slash-menu-title",children:g.title}),s.jsx("div",{className:"slash-menu-description",children:g.description})]})]},g.title))})},Tr=e=>{const{insertData:r,isVoid:n}=e;return e.isVoid=a=>a.type==="image"?!0:n(a),e.insertData=a=>{const o=a.getData("text/plain"),{files:d}=a;if(d&&d.length>0)for(const c of d){const u=new FileReader,[p]=c.type.split("/");p==="image"&&(u.addEventListener("load",()=>{const b=u.result;Ge(e,b)}),u.readAsDataURL(c))}else rt(o)?Ge(e,o):r(a)},e},Ge=(e,r)=>{const a={type:"image",url:r,children:[{text:""}]};l.Transforms.insertNodes(e,a)},Nr=e=>{const{deleteBackward:r,deleteForward:n,insertBreak:a}=e;return e.deleteBackward=(...o)=>{const{selection:d}=e;if(d&&l.Range.isCollapsed(d)){const[c]=l.Editor.nodes(e,{match:u=>u.type==="table-cell"});if(c){const[,u]=c,p=l.Editor.start(e,u);if(l.Point.equals(d.anchor,p))return}}r(...o)},e.deleteForward=(...o)=>{const{selection:d}=e;if(d&&l.Range.isCollapsed(d)){const[c]=l.Editor.nodes(e,{match:u=>u.type==="table-cell"});if(c){const[,u]=c,p=l.Editor.end(e,u);if(l.Point.equals(d.anchor,p))return}}n(...o)},e.insertBreak=(...o)=>{const{selection:d}=e;if(d){const[c]=l.Editor.nodes(e,{match:u=>u.type==="table"});if(c)return}a(...o)},e},zr=e=>{const{insertData:r,insertText:n,isInline:a}=e;return e.isInline=o=>o.type==="link"?!0:a(o),e.insertText=o=>{o&&Qe(o)?Ze(e,o):n(o)},e.insertData=o=>{const d=o.getData("text/plain");d&&Qe(d)?Ze(e,d):r(o)},e},Qe=e=>{try{return new URL(e),!0}catch{return!1}},Ze=(e,r)=>{Sr(e)&&Mr(e);const{selection:n}=e,a=n&&l.Range.isCollapsed(n),o={type:"link",url:r,children:a?[{text:r}]:[]};a?l.Transforms.insertNodes(e,o):(l.Transforms.wrapNodes(e,o,{split:!0}),l.Transforms.collapse(e,{edge:"end"}))},Mr=e=>{l.Transforms.unwrapNodes(e,{match:r=>r.type==="link"})},Sr=e=>{const[r]=l.Editor.nodes(e,{match:n=>n.type==="link"});return!!r},lt=e=>e.map(r=>it(r)).join(""),it=e=>{if(l.Text.isText(e)){let n=ee(e.text);return e.bold&&(n=`<strong>${n}</strong>`),e.italic&&(n=`<em>${n}</em>`),e.underline&&(n=`<u>${n}</u>`),e.strikethrough&&(n=`<s>${n}</s>`),e["font-size-small"]?n=`<span style="font-size: 12px;">${n}</span>`:e["font-size-large"]?n=`<span style="font-size: 16px;">${n}</span>`:e["font-size-extra-large"]&&(n=`<span style="font-size: 18px;">${n}</span>`),e.color&&(n=`<span style="color: ${e.color};">${n}</span>`),e.backgroundColor&&(n=`<span style="background-color: ${e.backgroundColor};">${n}</span>`),n}const r=e.children.map(n=>it(n)).join("");switch(e.type){case"paragraph":return`<p${K(e)}>${r}</p>`;case"heading-one":return`<h1${K(e)}>${r}</h1>`;case"heading-two":return`<h2${K(e)}>${r}</h2>`;case"heading-three":return`<h3${K(e)}>${r}</h3>`;case"blockquote":return`<blockquote${K(e)}>${r}</blockquote>`;case"bulleted-list":return`<ul>${r}</ul>`;case"numbered-list":return`<ol>${r}</ol>`;case"list-item":return`<li>${r}</li>`;case"link":return`<a href="${ee(e.url)}">${r}</a>`;case"image":const n=e.width?`width: ${e.width}px; `:"";return`<img src="${ee(e.url)}" alt="${ee(e.alt||"")}" style="${n}max-width: 100%; height: auto;" />`;case"table":return`<table border="1" style="border-collapse: collapse; width: 100%;">${r}</table>`;case"table-row":return`<tr>${r}</tr>`;case"table-cell":const a=e.header?"th":"td";return`<${a} style="border: 1px solid #ccc; padding: 8px;">${r}</${a}>`;default:return r}},K=e=>e.align?` style="text-align: ${e.align};"`:"",ct=e=>{const r=new DOMParser().parseFromString(e,"text/html");return ut(r.body.childNodes)},ut=e=>{const r=[];for(const n of e){const a=_r(n);a&&(Array.isArray(a)?r.push(...a):r.push(a))}return r.length>0?r:[{type:"paragraph",children:[{text:""}]}]},_r=e=>{if(e.nodeType===Node.TEXT_NODE)return{text:e.textContent};if(e.nodeType!==Node.ELEMENT_NODE)return null;const r=ut(e.childNodes),n={children:r},a=e.getAttribute("style");if(a&&a.includes("text-align:")){const o=a.match(/text-align:\s*([^;]+)/);o&&(n.align=o[1].trim())}switch(e.nodeName.toLowerCase()){case"p":return{...n,type:"paragraph"};case"h1":return{...n,type:"heading-one"};case"h2":return{...n,type:"heading-two"};case"h3":return{...n,type:"heading-three"};case"blockquote":return{...n,type:"blockquote"};case"ul":return{...n,type:"bulleted-list"};case"ol":return{...n,type:"numbered-list"};case"li":return{...n,type:"list-item"};case"a":return{...n,type:"link",url:e.getAttribute("href")};case"img":const o=e.getAttribute("style");let d=300;if(o&&o.includes("width:")){const c=o.match(/width:\s*(\d+)px/);c&&(d=parseInt(c[1]))}return{type:"image",url:e.getAttribute("src"),alt:e.getAttribute("alt")||"",width:d,children:[{text:""}]};case"table":return{...n,type:"table"};case"tr":return{...n,type:"table-row"};case"td":return{...n,type:"table-cell"};case"th":return{...n,type:"table-cell",header:!0};case"strong":case"b":return ne(r,"bold");case"em":case"i":return ne(r,"italic");case"u":return ne(r,"underline");case"s":case"strike":return ne(r,"strikethrough");case"span":return Dr(e,r);case"br":return{text:`
|
|
15
|
+
`};case"div":return r.length>0?{...n,type:"paragraph"}:null;default:return r}},ne=(e,r)=>e.map(n=>n.text!==void 0?{...n,[r]:!0}:n),Dr=(e,r)=>{const n=e.getAttribute("style");let a={};if(n){n.includes("font-size: 12px")?a["font-size-small"]=!0:n.includes("font-size: 16px")?a["font-size-large"]=!0:n.includes("font-size: 18px")&&(a["font-size-extra-large"]=!0);const o=n.match(/color:\s*([^;]+)/);o&&(a.color=o[1].trim());const d=n.match(/background-color:\s*([^;]+)/);d&&(a.backgroundColor=d[1].trim())}return Object.keys(a).length>0?r.map(o=>o.text!==void 0?{...o,...a}:o):r},Pr=(e,r,n)=>{const[a,o]=w.useState(()=>r?typeof r=="string"?ct(r):r:e||[{type:"paragraph",children:[{text:""}]}]);return{editorValue:a,handleChange:(c,u)=>{if(o(c),u&&u(c),n){const p=c.length===1&&c[0].type==="paragraph"&&c[0].children.length===1&&c[0].children[0].text==="",b=p?"":lt(c);n(b,p?[]:c)}}}},$r=e=>{const[r,n]=w.useState(null),a=w.useCallback(d=>{const{selection:c}=e;if(c&&l.Range.isCollapsed(c)){const[u]=l.Range.edges(c),p=l.Editor.before(e,u,{unit:"word"}),b=p&&l.Editor.before(e,p),y=b&&l.Editor.range(e,b,u),g=y&&l.Editor.string(e,y),h=g&&g.match(/\/(\w*)$/),E=l.Editor.after(e,u),D=l.Editor.range(e,u,E),I=l.Editor.string(e,D).match(/^(\s|$)/);n(h&&I?{target:y,search:h[1]}:null)}else n(null)},[e]),o=w.useCallback(()=>{n(null)},[]);return{slashMenu:r,handleSlashMenu:a,closeSlashMenu:o}},ve=(e,r)=>{const n=l.Editor.marks(e);(n?n[r]===!0:!1)?l.Editor.removeMark(e,r):l.Editor.addMark(e,r,!0)},Ir=e=>w.useCallback(r=>{if(r.ctrlKey)switch(r.key){case"b":{r.preventDefault(),ve(e,"bold");break}case"i":{r.preventDefault(),ve(e,"italic");break}case"u":{r.preventDefault(),ve(e,"underline");break}case"z":{r.shiftKey?(r.preventDefault(),e.redo()):(r.preventDefault(),e.undo());break}}},[e]),dt=({value:e,onChange:r,placeholder:n="Enter some text...",readOnly:a=!1,className:o="",initialValue:d=null,features:c=["bold","italic","underline","fontSize"]})=>{const u=w.useMemo(()=>zr(Nr(Tr(qt.withHistory(P.withReact(l.createEditor()))))),[]),{editorValue:p,handleChange:b}=Pr(e,d,r),{slashMenu:y,handleSlashMenu:g,closeSlashMenu:h}=$r(u),E=Ir(u),D=w.useCallback(N=>s.jsx(jr,{...N}),[]),$=w.useCallback(N=>s.jsx(Cr,{...N}),[]),I=w.useCallback(N=>{b(N,g)},[b,g]);return s.jsx("div",{className:`scrible-editor ${o}`,children:s.jsxs(P.Slate,{editor:u,initialValue:p,onChange:I,children:[!a&&s.jsx(wr,{features:c}),s.jsxs("div",{className:"editor-container",children:[s.jsx(P.Editable,{renderElement:D,renderLeaf:$,placeholder:n,onKeyDown:E,readOnly:a,className:"editor-content"}),y&&s.jsx(Rr,{target:y.target,search:y.search,onClose:h})]})]})})};exports.ScribleEditor=dt;exports.default=dt;exports.deleteTableColumn=tr;exports.deleteTableRow=er;exports.deserialize=ct;exports.getBackgroundColor=tt;exports.getTextColor=et;exports.insertImage=be;exports.insertLink=nt;exports.insertTable=xe;exports.insertTableColumn=Zt;exports.insertTableRow=Qt;exports.isBlockActive=le;exports.isImageUrl=rt;exports.isLinkActive=ot;exports.isMarkActive=V;exports.serialize=lt;exports.setBackgroundColor=ae;exports.setTextColor=se;exports.toggleAlignment=J;exports.toggleBlock=oe;exports.toggleMark=B;exports.unwrapLink=at;exports.wrapLink=st;
|