@anilkumarteach/editor-ak 0.1.1 → 0.1.2

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/package.json CHANGED
@@ -1,25 +1,28 @@
1
1
  {
2
2
  "name": "@anilkumarteach/editor-ak",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
+ "description": "Rich Text Editor for React",
4
5
  "type": "module",
5
6
  "main": "dist/index.cjs",
6
7
  "module": "dist/index.js",
7
8
  "types": "dist/index.d.ts",
8
- "files": [
9
- "dist"
10
- ],
9
+ "files": ["dist"],
10
+
11
+ "engines": {
12
+ "node": ">=16"
13
+ },
14
+
11
15
  "peerDependencies": {
12
- "react": "^18",
13
- "react-dom": "^18"
16
+ "react": ">=18",
17
+ "react-dom": ">=18"
14
18
  },
19
+
15
20
  "scripts": {
16
21
  "build": "vite build"
17
22
  },
23
+
18
24
  "devDependencies": {
19
- "@vitejs/plugin-react": "^5.1.2",
20
- "vite": "^7.3.0"
21
- },
22
- "dependencies": {
23
- "@anilkumarteach/editor-ak": "file:anilkumarteach-editor-ak-0.1.1.tgz"
25
+ "vite": "^7.3.0",
26
+ "@vitejs/plugin-react": "^5.1.2"
24
27
  }
25
28
  }
@@ -1,126 +0,0 @@
1
- (function($,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],o):($=typeof globalThis<"u"?globalThis:$||self,o($.EditorUI={},$.require$$0))})(this,(function($,o){"use strict";var ve={exports:{}},ue={};var nt;function Tt(){if(nt)return ue;nt=1;var n=o,r=Symbol.for("react.element"),u=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,l=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function d(h,g,y){var x,k={},p=null,m=null;y!==void 0&&(p=""+y),g.key!==void 0&&(p=""+g.key),g.ref!==void 0&&(m=g.ref);for(x in g)s.call(g,x)&&!a.hasOwnProperty(x)&&(k[x]=g[x]);if(h&&h.defaultProps)for(x in g=h.defaultProps,g)k[x]===void 0&&(k[x]=g[x]);return{$$typeof:r,type:h,key:p,ref:m,props:k,_owner:l.current}}return ue.Fragment=u,ue.jsx=d,ue.jsxs=d,ue}var fe={};var rt;function Et(){return rt||(rt=1,process.env.NODE_ENV!=="production"&&(function(){var n=o,r=Symbol.for("react.element"),u=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),d=Symbol.for("react.provider"),h=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),b=Symbol.iterator,N="@@iterator";function M(t){if(t===null||typeof t!="object")return null;var i=b&&t[b]||t[N];return typeof i=="function"?i:null}var R=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function I(t){{for(var i=arguments.length,f=new Array(i>1?i-1:0),j=1;j<i;j++)f[j-1]=arguments[j];Q("error",t,f)}}function Q(t,i,f){{var j=R.ReactDebugCurrentFrame,T=j.getStackAddendum();T!==""&&(i+="%s",f=f.concat([T]));var _=f.map(function(S){return String(S)});_.unshift("Warning: "+i),Function.prototype.apply.call(console[t],console,_)}}var E=!1,F=!1,H=!1,se=!1,we=!1,Ce;Ce=Symbol.for("react.module.reference");function Ve(t){return!!(typeof t=="string"||typeof t=="function"||t===s||t===a||we||t===l||t===y||t===x||se||t===m||E||F||H||typeof t=="object"&&t!==null&&(t.$$typeof===p||t.$$typeof===k||t.$$typeof===d||t.$$typeof===h||t.$$typeof===g||t.$$typeof===Ce||t.getModuleId!==void 0))}function Ne(t,i,f){var j=t.displayName;if(j)return j;var T=i.displayName||i.name||"";return T!==""?f+"("+T+")":f}function B(t){return t.displayName||"Context"}function G(t){if(t==null)return null;if(typeof t.tag=="number"&&I("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 s:return"Fragment";case u:return"Portal";case a:return"Profiler";case l:return"StrictMode";case y:return"Suspense";case x:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case h:var i=t;return B(i)+".Consumer";case d:var f=t;return B(f._context)+".Provider";case g:return Ne(t,t.render,"ForwardRef");case k:var j=t.displayName||null;return j!==null?j:G(t.type)||"Memo";case p:{var T=t,_=T._payload,S=T._init;try{return G(S(_))}catch{return null}}}return null}var J=Object.assign,Z=0,Le,Se,me,Re,Te,Ee,W;function z(){}z.__reactDisabledLog=!0;function Fe(){{if(Z===0){Le=console.log,Se=console.info,me=console.warn,Re=console.error,Te=console.group,Ee=console.groupCollapsed,W=console.groupEnd;var t={configurable:!0,enumerable:!0,value:z,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}Z++}}function Ue(){{if(Z--,Z===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:J({},t,{value:Le}),info:J({},t,{value:Se}),warn:J({},t,{value:me}),error:J({},t,{value:Re}),group:J({},t,{value:Te}),groupCollapsed:J({},t,{value:Ee}),groupEnd:J({},t,{value:W})})}Z<0&&I("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var he=R.ReactCurrentDispatcher,pe;function X(t,i,f){{if(pe===void 0)try{throw Error()}catch(T){var j=T.stack.trim().match(/\n( *(at )?)/);pe=j&&j[1]||""}return`
2
- `+pe+t}}var xe=!1,q;{var ze=typeof WeakMap=="function"?WeakMap:Map;q=new ze}function oe(t,i){if(!t||xe)return"";{var f=q.get(t);if(f!==void 0)return f}var j;xe=!0;var T=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var _;_=he.current,he.current=null,Fe();try{if(i){var S=function(){throw Error()};if(Object.defineProperty(S.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(S,[])}catch(U){j=U}Reflect.construct(t,[],S)}else{try{S.call()}catch(U){j=U}t.call(S.prototype)}}else{try{throw Error()}catch(U){j=U}t()}}catch(U){if(U&&j&&typeof U.stack=="string"){for(var C=U.stack.split(`
3
- `),V=j.stack.split(`
4
- `),O=C.length-1,P=V.length-1;O>=1&&P>=0&&C[O]!==V[P];)P--;for(;O>=1&&P>=0;O--,P--)if(C[O]!==V[P]){if(O!==1||P!==1)do if(O--,P--,P<0||C[O]!==V[P]){var Y=`
5
- `+C[O].replace(" at new "," at ");return t.displayName&&Y.includes("<anonymous>")&&(Y=Y.replace("<anonymous>",t.displayName)),typeof t=="function"&&q.set(t,Y),Y}while(O>=1&&P>=0);break}}}finally{xe=!1,he.current=_,Ue(),Error.prepareStackTrace=T}var de=t?t.displayName||t.name:"",re=de?X(de):"";return typeof t=="function"&&q.set(t,re),re}function ge(t,i,f){return oe(t,!1)}function ae(t){var i=t.prototype;return!!(i&&i.isReactComponent)}function ie(t,i,f){if(t==null)return"";if(typeof t=="function")return oe(t,ae(t));if(typeof t=="string")return X(t);switch(t){case y:return X("Suspense");case x:return X("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case g:return ge(t.render);case k:return ie(t.type,i,f);case p:{var j=t,T=j._payload,_=j._init;try{return ie(_(T),i,f)}catch{}}}return""}var te=Object.prototype.hasOwnProperty,_e={},Me=R.ReactDebugCurrentFrame;function le(t){if(t){var i=t._owner,f=ie(t.type,t._source,i?i.type:null);Me.setExtraStackFrame(f)}else Me.setExtraStackFrame(null)}function Ye(t,i,f,j,T){{var _=Function.call.bind(te);for(var S in t)if(_(t,S)){var C=void 0;try{if(typeof t[S]!="function"){var V=Error((j||"React class")+": "+f+" type `"+S+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[S]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw V.name="Invariant Violation",V}C=t[S](i,S,j,f,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(O){C=O}C&&!(C instanceof Error)&&(le(T),I("%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).",j||"React class",f,S,typeof C),le(null)),C instanceof Error&&!(C.message in _e)&&(_e[C.message]=!0,le(T),I("Failed %s type: %s",f,C.message),le(null))}}}var Je=Array.isArray;function be(t){return Je(t)}function Ke(t){{var i=typeof Symbol=="function"&&Symbol.toStringTag,f=i&&t[Symbol.toStringTag]||t.constructor.name||"Object";return f}}function c(t){try{return w(t),!1}catch{return!0}}function w(t){return""+t}function L(t){if(c(t))return I("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ke(t)),w(t)}var v=R.ReactCurrentOwner,D={key:!0,ref:!0,__self:!0,__source:!0},K,ne;function Ge(t){if(te.call(t,"ref")){var i=Object.getOwnPropertyDescriptor(t,"ref").get;if(i&&i.isReactWarning)return!1}return t.ref!==void 0}function Xe(t){if(te.call(t,"key")){var i=Object.getOwnPropertyDescriptor(t,"key").get;if(i&&i.isReactWarning)return!1}return t.key!==void 0}function Qe(t,i){typeof t.ref=="string"&&v.current}function Ze(t,i){{var f=function(){K||(K=!0,I("%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 Ie(t,i){{var f=function(){ne||(ne=!0,I("%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 De=function(t,i,f,j,T,_,S){var C={$$typeof:r,type:t,key:i,ref:f,props:S,_owner:_};return C._store={},Object.defineProperty(C._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(C,"_self",{configurable:!1,enumerable:!1,writable:!1,value:j}),Object.defineProperty(C,"_source",{configurable:!1,enumerable:!1,writable:!1,value:T}),Object.freeze&&(Object.freeze(C.props),Object.freeze(C)),C};function cn(t,i,f,j,T){{var _,S={},C=null,V=null;f!==void 0&&(L(f),C=""+f),Xe(i)&&(L(i.key),C=""+i.key),Ge(i)&&(V=i.ref,Qe(i,T));for(_ in i)te.call(i,_)&&!D.hasOwnProperty(_)&&(S[_]=i[_]);if(t&&t.defaultProps){var O=t.defaultProps;for(_ in O)S[_]===void 0&&(S[_]=O[_])}if(C||V){var P=typeof t=="function"?t.displayName||t.name||"Unknown":t;C&&Ze(S,P),V&&Ie(S,P)}return De(t,C,V,T,j,v.current,S)}}var qe=R.ReactCurrentOwner,yt=R.ReactDebugCurrentFrame;function ce(t){if(t){var i=t._owner,f=ie(t.type,t._source,i?i.type:null);yt.setExtraStackFrame(f)}else yt.setExtraStackFrame(null)}var $e;$e=!1;function et(t){return typeof t=="object"&&t!==null&&t.$$typeof===r}function wt(){{if(qe.current){var t=G(qe.current.type);if(t)return`
6
-
7
- Check the render method of \``+t+"`."}return""}}function dn(t){return""}var Ct={};function un(t){{var i=wt();if(!i){var f=typeof t=="string"?t:t.displayName||t.name;f&&(i=`
8
-
9
- Check the top-level render call using <`+f+">.")}return i}}function Nt(t,i){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var f=un(i);if(Ct[f])return;Ct[f]=!0;var j="";t&&t._owner&&t._owner!==qe.current&&(j=" It was passed a child from "+G(t._owner.type)+"."),ce(t),I('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',f,j),ce(null)}}function Lt(t,i){{if(typeof t!="object")return;if(be(t))for(var f=0;f<t.length;f++){var j=t[f];et(j)&&Nt(j,i)}else if(et(t))t._store&&(t._store.validated=!0);else if(t){var T=M(t);if(typeof T=="function"&&T!==t.entries)for(var _=T.call(t),S;!(S=_.next()).done;)et(S.value)&&Nt(S.value,i)}}}function fn(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===g||i.$$typeof===k))f=i.propTypes;else return;if(f){var j=G(i);Ye(f,t.props,"prop",j,t)}else if(i.PropTypes!==void 0&&!$e){$e=!0;var T=G(i);I("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",T||"Unknown")}typeof i.getDefaultProps=="function"&&!i.getDefaultProps.isReactClassApproved&&I("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function mn(t){{for(var i=Object.keys(t.props),f=0;f<i.length;f++){var j=i[f];if(j!=="children"&&j!=="key"){ce(t),I("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",j),ce(null);break}}t.ref!==null&&(ce(t),I("Invalid attribute `ref` supplied to `React.Fragment`."),ce(null))}}var St={};function Rt(t,i,f,j,T,_){{var S=Ve(t);if(!S){var C="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(C+=" 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 V=dn();V?C+=V:C+=wt();var O;t===null?O="null":be(t)?O="array":t!==void 0&&t.$$typeof===r?(O="<"+(G(t.type)||"Unknown")+" />",C=" Did you accidentally export a JSX literal instead of a component?"):O=typeof t,I("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",O,C)}var P=cn(t,i,f,T,_);if(P==null)return P;if(S){var Y=i.children;if(Y!==void 0)if(j)if(be(Y)){for(var de=0;de<Y.length;de++)Lt(Y[de],t);Object.freeze&&Object.freeze(Y)}else I("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 Lt(Y,t)}if(te.call(i,"key")){var re=G(t),U=Object.keys(i).filter(function(vn){return vn!=="key"}),tt=U.length>0?"{key: someKey, "+U.join(": ..., ")+": ...}":"{key: someKey}";if(!St[re+tt]){var bn=U.length>0?"{"+U.join(": ..., ")+": ...}":"{}";I(`A props object containing a "key" prop is being spread into JSX:
10
- let props = %s;
11
- <%s {...props} />
12
- React keys must be passed directly to JSX without using spread:
13
- let props = %s;
14
- <%s key={someKey} {...props} />`,tt,re,bn,re),St[re+tt]=!0}}return t===s?mn(P):fn(P),P}}function hn(t,i,f){return Rt(t,i,f,!0)}function pn(t,i,f){return Rt(t,i,f,!1)}var xn=pn,gn=hn;fe.Fragment=s,fe.jsx=xn,fe.jsxs=gn})()),fe}var st;function _t(){return st||(st=1,process.env.NODE_ENV==="production"?ve.exports=Tt():ve.exports=Et()),ve.exports}var e=_t();const ot=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"}),e.jsx("path",{d:"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"})]}),at=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"19",y1:"4",x2:"10",y2:"4"}),e.jsx("line",{x1:"14",y1:"20",x2:"5",y2:"20"}),e.jsx("line",{x1:"15",y1:"4",x2:"9",y2:"20"})]}),it=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),e.jsx("line",{x1:"4",y1:"20",x2:"20",y2:"20"})]}),lt=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),e.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),e.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]}),ct=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"8",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"8",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"8",y1:"18",x2:"21",y2:"18"}),e.jsx("line",{x1:"3",y1:"6",x2:"3.01",y2:"6"}),e.jsx("line",{x1:"3",y1:"12",x2:"3.01",y2:"12"}),e.jsx("line",{x1:"3",y1:"18",x2:"3.01",y2:"18"})]}),dt=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"10",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"10",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"10",y1:"18",x2:"21",y2:"18"}),e.jsx("path",{d:"M4 6h1v4"}),e.jsx("path",{d:"M4 10h2"}),e.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]}),ut=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"9 11 12 14 22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),ft=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"}),e.jsx("path",{d:"M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v4z"})]}),je=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]}),mt=({className:n="w-4 h-4"})=>e.jsx("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})}),ke=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),e.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),Mt=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M3 7v6h6"}),e.jsx("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]}),It=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 7v6h-6"}),e.jsx("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})]}),ht=({className:n="w-4 h-4"})=>e.jsx("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})}),Dt=({className:n="w-4 h-4"})=>e.jsx("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),pt=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 7 4 4 20 4 20 7"}),e.jsx("line",{x1:"9",y1:"20",x2:"15",y2:"20"}),e.jsx("line",{x1:"12",y1:"4",x2:"12",y2:"20"})]}),xt=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M4 12h8"}),e.jsx("path",{d:"M4 18V6"}),e.jsx("path",{d:"M12 18V6"}),e.jsx("path",{d:"m17 12 3-2v8"})]}),gt=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M4 12h8"}),e.jsx("path",{d:"M4 18V6"}),e.jsx("path",{d:"M12 18V6"}),e.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]}),bt=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M4 12h8"}),e.jsx("path",{d:"M4 18V6"}),e.jsx("path",{d:"M12 18V6"}),e.jsx("path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}),e.jsx("path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"})]}),ye=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),Oe=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e.jsx("polyline",{points:"21 15 16 10 5 21"})]}),Pe=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M3 9h18"}),e.jsx("path",{d:"M3 15h18"}),e.jsx("path",{d:"M9 3v18"}),e.jsx("path",{d:"M15 3v18"})]}),Ot=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),Pt=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("line",{x1:"10",y1:"9",x2:"8",y2:"9"})]}),vt=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),Ae=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),At=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),e.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),e.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]}),Ht=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"})]}),Bt=({className:n="w-4 h-4"})=>e.jsxs("svg",{className:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("circle",{cx:"10",cy:"13",r:"2"}),e.jsx("path",{d:"m20 17-1.09-1.09a2 2 0 0 0-2.82 0L10 22"})]}),He=({content:n,children:r,position:u="bottom",shortcut:s})=>{const[l,a]=o.useState(!1),[d,h]=o.useState({x:0,y:0}),g=o.useRef(null),y=o.useRef(null),x=o.useRef(),k=()=>{x.current=window.setTimeout(()=>{a(!0)},400)},p=()=>{x.current&&clearTimeout(x.current),a(!1)};return o.useEffect(()=>{if(l&&g.current&&y.current){const m=g.current.getBoundingClientRect(),b=y.current.getBoundingClientRect();let N=0,M=0;switch(u){case"top":N=m.left+(m.width-b.width)/2,M=m.top-b.height-8;break;case"bottom":N=m.left+(m.width-b.width)/2,M=m.bottom+8;break;case"left":N=m.left-b.width-8,M=m.top+(m.height-b.height)/2;break;case"right":N=m.right+8,M=m.top+(m.height-b.height)/2;break}N=Math.max(8,Math.min(N,window.innerWidth-b.width-8)),M=Math.max(8,Math.min(M,window.innerHeight-b.height-8)),h({x:N,y:M})}},[l,u]),o.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]),e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:g,onMouseEnter:k,onMouseLeave:p,onFocus:k,onBlur:p,className:"inline-flex",children:r}),l&&e.jsxs("div",{ref:y,className:"fixed z-50 px-2.5 py-1.5 text-xs font-medium rounded-md shadow-lg animate-fade-in pointer-events-none bg-tooltip text-tooltip-foreground",style:{left:d.x,top:d.y},children:[e.jsx("span",{children:n}),s&&e.jsx("span",{className:"ml-2 opacity-70 font-mono",children:s})]})]})},A=({icon:n,tooltip:r,shortcut:u,isActive:s=!1,onClick:l,disabled:a=!1})=>{const d="p-2 rounded-md transition-all duration-150 flex items-center justify-center hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 disabled:opacity-40 disabled:cursor-not-allowed",h=s?"bg-accent text-accent-foreground":"";return e.jsx(He,{content:r,shortcut:u,children:e.jsx("button",{type:"button",onClick:l,disabled:a,className:`${d} ${h}`,"aria-pressed":s,children:n})})},Be=[{name:"DM Sans",value:"dm-sans",className:"font-sans-editor"},{name:"Merriweather",value:"merriweather",className:"font-serif-editor"},{name:"Playfair Display",value:"playfair",className:"font-display-editor"},{name:"JetBrains Mono",value:"jetbrains",className:"font-mono-editor"},{name:"Arial",value:"arial",className:"font-arial"},{name:"Georgia",value:"georgia",className:"font-georgia"},{name:"Verdana",value:"verdana",className:"font-verdana"},{name:"Courier New",value:"courier",className:"font-courier"},{name:"Times New Roman",value:"times",className:"font-times"}],Wt=({currentFont:n,onFontChange:r})=>{const[u,s]=o.useState(!1),l=o.useRef(null),a=Be.find(d=>d.value===n)||Be[0];return o.useEffect(()=>{const d=h=>{l.current&&!l.current.contains(h.target)&&s(!1)};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[]),e.jsxs("div",{className:"relative",ref:l,children:[e.jsx(He,{content:"Font family",children:e.jsxs("button",{type:"button",onClick:()=>s(!u),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md transition-all duration-150 hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 text-sm font-medium min-w-[140px] justify-between ${u?"bg-secondary":""}`,children:[e.jsx("span",{className:a.className,children:a.name}),e.jsx(ht,{className:`w-4 h-4 transition-transform duration-200 ${u?"rotate-180":""}`})]})}),u&&e.jsx("div",{className:"absolute top-full left-0 mt-1 w-52 py-1 rounded-lg shadow-dropdown animate-scale-in z-50 bg-popover border border-border",children:Be.map(d=>e.jsxs("button",{type:"button",onClick:()=>{r(d),s(!1)},className:`w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors hover:bg-accent ${d.value===n?"bg-accent":""}`,children:[e.jsx("span",{className:`flex-1 text-left ${d.className}`,children:d.name}),d.value===n&&e.jsx(Dt,{className:"w-4 h-4 text-primary"})]},d.value))})]})},We=[{name:"Paragraph",value:"p",icon:e.jsx(pt,{className:"w-4 h-4"})},{name:"Heading 1",value:"h1",icon:e.jsx(xt,{className:"w-4 h-4"})},{name:"Heading 2",value:"h2",icon:e.jsx(gt,{className:"w-4 h-4"})},{name:"Heading 3",value:"h3",icon:e.jsx(bt,{className:"w-4 h-4"})}],Vt=({currentHeading:n,onHeadingChange:r})=>{const[u,s]=o.useState(!1),l=o.useRef(null),a=We.find(d=>d.value===n)||We[0];return o.useEffect(()=>{const d=h=>{l.current&&!l.current.contains(h.target)&&s(!1)};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[]),e.jsxs("div",{className:"relative",ref:l,children:[e.jsx(He,{content:"Text style",children:e.jsxs("button",{type:"button",onClick:()=>s(!u),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md transition-all duration-150 hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 text-sm font-medium min-w-[120px] justify-between ${u?"bg-secondary":""}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[a.icon,a.name]}),e.jsx(ht,{className:`w-4 h-4 transition-transform duration-200 ${u?"rotate-180":""}`})]})}),u&&e.jsx("div",{className:"absolute top-full left-0 mt-1 w-44 py-1 rounded-lg shadow-dropdown animate-scale-in z-50 bg-popover border border-border",children:We.map(d=>e.jsxs("button",{type:"button",onClick:()=>{r(d.value),s(!1)},className:`w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors hover:bg-accent ${d.value===n?"bg-accent":""}`,children:[d.icon,e.jsx("span",{className:`${d.value==="h1"?"text-lg font-bold":""} ${d.value==="h2"?"text-base font-semibold":""} ${d.value==="h3"?"text-sm font-semibold":""}`,children:d.name})]},d.value))})]})},Ft=({formatState:n,currentFont:r,onFormat:u,onFontChange:s,onHeadingChange:l,onUndo:a,onRedo:d,canUndo:h,canRedo:g,onInsertLink:y})=>e.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b rounded-t-lg flex-wrap bg-toolbar border-toolbar-border",children:[e.jsxs("div",{className:"flex items-center gap-0.5 mr-2",children:[e.jsx(A,{icon:e.jsx(Mt,{className:"w-4 h-4"}),tooltip:"Undo",shortcut:"⌘Z",onClick:a,disabled:!h}),e.jsx(A,{icon:e.jsx(It,{className:"w-4 h-4"}),tooltip:"Redo",shortcut:"⌘⇧Z",onClick:d,disabled:!g})]}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(Wt,{currentFont:r,onFontChange:s}),e.jsx(Vt,{currentHeading:n.heading,onHeadingChange:l}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(A,{icon:e.jsx(ot,{className:"w-4 h-4"}),tooltip:"Bold",shortcut:"⌘B",isActive:n.bold,onClick:()=>u("bold")}),e.jsx(A,{icon:e.jsx(at,{className:"w-4 h-4"}),tooltip:"Italic",shortcut:"⌘I",isActive:n.italic,onClick:()=>u("italic")}),e.jsx(A,{icon:e.jsx(it,{className:"w-4 h-4"}),tooltip:"Underline",shortcut:"⌘U",isActive:n.underline,onClick:()=>u("underline")}),e.jsx(A,{icon:e.jsx(lt,{className:"w-4 h-4"}),tooltip:"Strikethrough",shortcut:"⌘⇧S",isActive:n.strikethrough,onClick:()=>u("strikethrough")})]}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(A,{icon:e.jsx(ct,{className:"w-4 h-4"}),tooltip:"Bullet list",shortcut:"⌘⇧8",isActive:n.unorderedList,onClick:()=>u("unorderedList")}),e.jsx(A,{icon:e.jsx(dt,{className:"w-4 h-4"}),tooltip:"Numbered list",shortcut:"⌘⇧7",isActive:n.orderedList,onClick:()=>u("orderedList")}),e.jsx(A,{icon:e.jsx(ut,{className:"w-4 h-4"}),tooltip:"Task list",shortcut:"⌘⇧9",isActive:n.taskList,onClick:()=>u("taskList")})]}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(A,{icon:e.jsx(ft,{className:"w-4 h-4"}),tooltip:"Blockquote",shortcut:"⌘⇧B",isActive:n.blockquote,onClick:()=>u("blockquote")}),e.jsx(A,{icon:e.jsx(je,{className:"w-4 h-4"}),tooltip:"Code block",shortcut:"⌘⇧C",isActive:n.code,onClick:()=>u("code")}),e.jsx(A,{icon:e.jsx(mt,{className:"w-4 h-4"}),tooltip:"Horizontal rule",onClick:()=>u("horizontalRule")})]}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(A,{icon:e.jsx(ke,{className:"w-4 h-4"}),tooltip:"Insert link",shortcut:"⌘K",onClick:y})]}),Ut=({formatState:n,onFormat:r,onInsertLink:u,editorRef:s})=>{const[l,a]=o.useState(!1),[d,h]=o.useState({x:0,y:0}),g=o.useRef(null);return o.useEffect(()=>{const y=()=>{const x=window.getSelection();if(!x||x.isCollapsed||!s.current){a(!1);return}const k=x.getRangeAt(0);if(!s.current.contains(k.commonAncestorContainer)){a(!1);return}if(!x.toString().trim()){a(!1);return}const m=k.getBoundingClientRect();let b=m.left+m.width/2,N=m.top-50;if(g.current){const M=g.current.offsetWidth||300;b=Math.max(M/2+8,Math.min(b,window.innerWidth-M/2-8))}N<10&&(N=m.bottom+10),h({x:b,y:N}),a(!0)};return document.addEventListener("selectionchange",y),()=>document.removeEventListener("selectionchange",y)},[s]),l?e.jsxs("div",{ref:g,className:"fixed z-50 flex items-center gap-0.5 px-2 py-1.5 rounded-lg shadow-floating animate-scale-in bg-popover border border-border",style:{left:d.x,top:d.y,transform:"translateX(-50%)"},onMouseDown:y=>y.preventDefault(),children:[e.jsx(A,{icon:e.jsx(ot,{className:"w-4 h-4"}),tooltip:"Bold",shortcut:"⌘B",isActive:n.bold,onClick:()=>r("bold")}),e.jsx(A,{icon:e.jsx(at,{className:"w-4 h-4"}),tooltip:"Italic",shortcut:"⌘I",isActive:n.italic,onClick:()=>r("italic")}),e.jsx(A,{icon:e.jsx(it,{className:"w-4 h-4"}),tooltip:"Underline",shortcut:"⌘U",isActive:n.underline,onClick:()=>r("underline")}),e.jsx(A,{icon:e.jsx(lt,{className:"w-4 h-4"}),tooltip:"Strikethrough",isActive:n.strikethrough,onClick:()=>r("strikethrough")}),e.jsx("div",{className:"w-px h-5 bg-border mx-1"}),e.jsx(A,{icon:e.jsx(je,{className:"w-4 h-4"}),tooltip:"Inline code",isActive:n.code,onClick:()=>r("inlineCode")}),e.jsx(A,{icon:e.jsx(ke,{className:"w-4 h-4"}),tooltip:"Insert link",shortcut:"⌘K",onClick:u})]}):null},zt=({isOpen:n,onClose:r,onInsert:u,selectedText:s=""})=>{const[l,a]=o.useState(""),[d,h]=o.useState(s),g=o.useRef(null);o.useEffect(()=>{n&&(h(s),a(""),setTimeout(()=>g.current?.focus(),100))},[n,s]);const y=x=>{if(x.preventDefault(),l.trim()){let k=l.trim();!k.startsWith("http://")&&!k.startsWith("https://")&&(k="https://"+k),u(k,d||void 0),r()}};return n?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm animate-fade-in",children:e.jsxs("div",{className:"w-full max-w-md p-6 rounded-xl shadow-floating animate-scale-in bg-card border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-foreground",children:[e.jsx(ke,{className:"w-5 h-5"}),e.jsx("h2",{className:"text-lg font-semibold",children:"Insert Link"})]}),e.jsx("button",{type:"button",onClick:r,className:"p-1 rounded-md hover:bg-secondary transition-colors",children:e.jsx(ye,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-foreground",children:"URL"}),e.jsx("input",{ref:g,type:"text",value:l,onChange:x=>a(x.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 rounded-lg border transition-colors bg-background border-input focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent placeholder:text-muted-foreground"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-foreground",children:"Text (optional)"}),e.jsx("input",{type:"text",value:d,onChange:x=>h(x.target.value),placeholder:"Link text",className:"w-full px-3 py-2 rounded-lg border transition-colors bg-background border-input focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent placeholder:text-muted-foreground"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx("button",{type:"button",onClick:r,className:"px-4 py-2 rounded-lg font-medium transition-colors bg-secondary text-secondary-foreground hover:bg-secondary/80",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:!l.trim(),className:"px-4 py-2 rounded-lg font-medium transition-colors bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed",children:"Insert"})]})]})]})}):null},Yt=[{id:"paragraph",label:"Text",description:"Plain text paragraph",icon:e.jsx(pt,{className:"w-4 h-4"}),action:"paragraph",category:"Basic"},{id:"h1",label:"Heading 1",description:"Large section heading",icon:e.jsx(xt,{className:"w-4 h-4"}),action:"h1",category:"Headings"},{id:"h2",label:"Heading 2",description:"Medium section heading",icon:e.jsx(gt,{className:"w-4 h-4"}),action:"h2",category:"Headings"},{id:"h3",label:"Heading 3",description:"Small section heading",icon:e.jsx(bt,{className:"w-4 h-4"}),action:"h3",category:"Headings"},{id:"bulletList",label:"Bullet List",description:"Create a bulleted list",icon:e.jsx(ct,{className:"w-4 h-4"}),action:"unorderedList",category:"Lists"},{id:"numberedList",label:"Numbered List",description:"Create a numbered list",icon:e.jsx(dt,{className:"w-4 h-4"}),action:"orderedList",category:"Lists"},{id:"taskList",label:"Task List",description:"Create a task checklist",icon:e.jsx(ut,{className:"w-4 h-4"}),action:"taskList",category:"Lists"},{id:"blockquote",label:"Quote",description:"Create a blockquote",icon:e.jsx(ft,{className:"w-4 h-4"}),action:"blockquote",category:"Blocks"},{id:"codeBlock",label:"Code Block",description:"Add a code snippet",icon:e.jsx(je,{className:"w-4 h-4"}),action:"code",category:"Blocks"},{id:"divider",label:"Divider",description:"Visual separator line",icon:e.jsx(mt,{className:"w-4 h-4"}),action:"horizontalRule",category:"Blocks"},{id:"table",label:"Table",description:"Insert a table",icon:e.jsx(Pe,{className:"w-4 h-4"}),action:"table",category:"Advanced"},{id:"image",label:"Image",description:"Upload or embed image",icon:e.jsx(Oe,{className:"w-4 h-4"}),action:"image",category:"Advanced"}],Jt=({isOpen:n,position:r,searchQuery:u,onSelect:s,onClose:l})=>{const[a,d]=o.useState(0),h=o.useRef(null),g=Yt.filter(p=>p.label.toLowerCase().includes(u.toLowerCase())||p.description.toLowerCase().includes(u.toLowerCase())),y=g.reduce((p,m)=>(p[m.category]||(p[m.category]=[]),p[m.category].push(m),p),{});o.useEffect(()=>{d(0)},[u]),o.useEffect(()=>{const p=m=>{h.current&&!h.current.contains(m.target)&&l()};return n&&document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[n,l]);const x=o.useCallback(p=>{if(n)switch(p.key){case"ArrowDown":p.preventDefault(),d(m=>(m+1)%g.length);break;case"ArrowUp":p.preventDefault(),d(m=>(m-1+g.length)%g.length);break;case"Enter":p.preventDefault(),g[a]&&s(g[a].action);break;case"Escape":p.preventDefault(),l();break}},[n,g,a,s,l]);if(o.useEffect(()=>(document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)),[x]),!n||g.length===0)return null;let k=0;return e.jsx("div",{ref:h,className:"fixed z-50 w-72 max-h-80 overflow-y-auto rounded-lg border shadow-lg animate-scale-in bg-popover border-border",style:{top:r.top,left:r.left},children:Object.entries(y).map(([p,m])=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:p}),m.map(b=>{const N=k++;return e.jsxs("button",{className:`w-full flex items-center gap-3 px-3 py-2 text-left transition-colors ${N===a?"bg-accent text-accent-foreground":"hover:bg-muted"}`,onClick:()=>s(b.action),onMouseEnter:()=>d(N),children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 flex items-center justify-center rounded-md bg-secondary text-secondary-foreground",children:b.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium",children:b.label}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:b.description})]})]},b.id)})]},p))})},Kt=({isOpen:n,onClose:r,onInsert:u})=>{const[s,l]=o.useState("upload"),[a,d]=o.useState(""),[h,g]=o.useState(""),[y,x]=o.useState(!1),[k,p]=o.useState(null),m=o.useRef(null),b=o.useCallback(E=>{if(!E.type.startsWith("image/")){alert("Please select an image file");return}const F=new FileReader;F.onload=H=>{const se=H.target?.result;p(se)},F.readAsDataURL(E)},[]),N=o.useCallback(E=>{E.preventDefault(),x(!1);const F=E.dataTransfer.files[0];F&&b(F)},[b]),M=o.useCallback(E=>{E.preventDefault(),x(!0)},[]),R=o.useCallback(E=>{E.preventDefault(),x(!1)},[]),I=()=>{const E=s==="upload"?k:a;E&&(u(E,h||void 0),Q())},Q=()=>{d(""),g(""),p(null),r()};return n?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm animate-fade-in",onClick:r,children:e.jsxs("div",{className:"w-full max-w-md rounded-xl border shadow-xl overflow-hidden animate-scale-in bg-card border-border",onClick:E=>E.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oe,{className:"w-5 h-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Insert Image"})]}),e.jsx("button",{onClick:r,className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(ye,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex border-b border-border",children:[e.jsxs("button",{onClick:()=>l("upload"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${s==="upload"?"border-b-2 border-primary text-primary":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(vt,{className:"w-4 h-4 inline mr-2"}),"Upload"]}),e.jsxs("button",{onClick:()=>l("url"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${s==="url"?"border-b-2 border-primary text-primary":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ke,{className:"w-4 h-4 inline mr-2"}),"URL"]})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[s==="upload"?e.jsxs("div",{onDrop:N,onDragOver:M,onDragLeave:R,onClick:()=>m.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${y?"border-primary bg-primary/5":"border-border hover:border-muted-foreground"} ${k?"border-solid":""}`,children:[k?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:k,alt:"Preview",className:"max-h-48 mx-auto rounded-lg"}),e.jsx("button",{onClick:E=>{E.stopPropagation(),p(null)},className:"absolute top-2 right-2 p-1 rounded-full bg-destructive text-destructive-foreground",children:e.jsx(ye,{className:"w-4 h-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(vt,{className:"w-10 h-10 mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Drag and drop an image, or click to select"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Supports: JPG, PNG, GIF, WebP"})]}),e.jsx("input",{ref:m,type:"file",accept:"image/*",className:"hidden",onChange:E=>{const F=E.target.files?.[0];F&&b(F)}})]}):e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",children:"Image URL"}),e.jsx("input",{type:"url",value:a,onChange:E=>d(E.target.value),placeholder:"https://example.com/image.jpg",className:"w-full px-3 py-2 rounded-lg border text-sm bg-background border-input focus:outline-none focus:ring-2 focus:ring-ring"}),a&&e.jsx("div",{className:"mt-3",children:e.jsx("img",{src:a,alt:"Preview",className:"max-h-32 mx-auto rounded-lg",onError:E=>{E.target.style.display="none"}})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5",children:"Alt Text (optional)"}),e.jsx("input",{type:"text",value:h,onChange:E=>g(E.target.value),placeholder:"Describe the image...",className:"w-full px-3 py-2 rounded-lg border text-sm bg-background border-input focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx("button",{onClick:Q,className:"px-4 py-2 rounded-lg text-sm font-medium transition-colors hover:bg-muted",children:"Cancel"}),e.jsx("button",{onClick:I,disabled:s==="upload"?!k:!a,className:"px-4 py-2 rounded-lg text-sm font-medium transition-colors bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed",children:"Insert Image"})]})]})]})}):null},Gt=({isOpen:n,onClose:r,onInsert:u})=>{const[s,l]=o.useState(3),[a,d]=o.useState(3),[h,g]=o.useState({row:0,col:0}),y=()=>{u(s,a),r()};return n?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm animate-fade-in",onClick:r,children:e.jsxs("div",{className:"w-full max-w-sm rounded-xl border shadow-xl overflow-hidden animate-scale-in bg-card border-border",onClick:x=>x.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pe,{className:"w-5 h-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Insert Table"})]}),e.jsx("button",{onClick:r,className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(ye,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"grid gap-1 p-2 rounded-lg bg-muted/50",children:Array.from({length:6},(x,k)=>e.jsx("div",{className:"flex gap-1",children:Array.from({length:6},(p,m)=>e.jsx("button",{className:`w-6 h-6 rounded border-2 transition-all ${k<h.row&&m<h.col?"bg-primary border-primary":"border-border hover:border-muted-foreground"}`,onMouseEnter:()=>g({row:k+1,col:m+1}),onClick:()=>{l(k+1),d(m+1)}},m))},k))}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:[h.row," × ",h.col]})]}),e.jsxs("div",{className:"flex items-center gap-4 justify-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Rows:"}),e.jsx("input",{type:"number",min:"1",max:"20",value:s,onChange:x=>l(Math.max(1,Math.min(20,parseInt(x.target.value)||1))),className:"w-16 px-2 py-1 rounded border text-sm text-center bg-background border-input focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Columns:"}),e.jsx("input",{type:"number",min:"1",max:"10",value:a,onChange:x=>d(Math.max(1,Math.min(10,parseInt(x.target.value)||1))),className:"w-16 px-2 py-1 rounded border text-sm text-center bg-background border-input focus:outline-none focus:ring-2 focus:ring-ring"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx("button",{onClick:r,className:"px-4 py-2 rounded-lg text-sm font-medium transition-colors hover:bg-muted",children:"Cancel"}),e.jsx("button",{onClick:y,className:"px-4 py-2 rounded-lg text-sm font-medium transition-colors bg-primary text-primary-foreground hover:bg-primary/90",children:"Insert Table"})]})]})]})}):null},Xt=({isOpen:n,onClose:r,versions:u,onRestore:s,onDelete:l})=>{if(!n)return null;const a=d=>{const h=new Date(d),y=new Date().getTime()-h.getTime();return y<6e4?"Just now":y<36e5?`${Math.floor(y/6e4)} min ago`:y<864e5?`${Math.floor(y/36e5)} hours ago`:h.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm animate-fade-in",onClick:r,children:e.jsxs("div",{className:"w-full max-w-md max-h-[70vh] rounded-xl border shadow-xl overflow-hidden animate-scale-in bg-card border-border",onClick:d=>d.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{className:"w-5 h-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Version History"})]}),e.jsx("button",{onClick:r,className:"text-muted-foreground hover:text-foreground transition-colors text-lg",children:"✕"})]}),e.jsx("div",{className:"overflow-y-auto max-h-96",children:u.length===0?e.jsxs("div",{className:"px-4 py-8 text-center text-muted-foreground",children:[e.jsx(Ae,{className:"w-10 h-10 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No versions saved yet"}),e.jsx("p",{className:"text-sm",children:"Changes are automatically saved"})]}):e.jsx("div",{className:"divide-y divide-border",children:[...u].reverse().map((d,h)=>e.jsxs("div",{className:"px-4 py-3 hover:bg-muted/50 transition-colors group",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:h===0?"Current Version":d.title}),e.jsx("div",{className:"text-xs text-muted-foreground",children:a(d.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[h!==0&&e.jsx("button",{onClick:()=>s(d.id),className:"p-1.5 rounded-md transition-colors hover:bg-primary/10 text-primary",title:"Restore this version",children:e.jsx(Ht,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>l(d.id),className:"p-1.5 rounded-md transition-colors hover:bg-destructive/10 text-destructive",title:"Delete this version",children:e.jsx(At,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground line-clamp-2",children:[d.content.replace(/<[^>]*>/g,"").slice(0,100),"..."]})]},d.id))})})]})})},Qt=({onExportHTML:n,onExportMarkdown:r,onExportPDF:u})=>{const[s,l]=o.useState(!1),a=o.useRef(null);o.useEffect(()=>{const h=g=>{a.current&&!a.current.contains(g.target)&&l(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);const d=[{label:"Export as HTML",icon:e.jsx(je,{className:"w-4 h-4"}),action:n},{label:"Export as Markdown",icon:e.jsx(Pt,{className:"w-4 h-4"}),action:r},{label:"Export as PDF",icon:e.jsx(Bt,{className:"w-4 h-4"}),action:u}];return e.jsxs("div",{ref:a,className:"relative",children:[e.jsxs("button",{onClick:()=>l(!s),className:`flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium transition-colors hover:bg-muted text-muted-foreground hover:text-foreground ${s?"bg-muted text-foreground":""}`,children:[e.jsx(Ot,{className:"w-4 h-4"}),"Export"]}),s&&e.jsx("div",{className:"absolute top-full right-0 mt-1 w-48 rounded-lg border shadow-lg overflow-hidden z-50 animate-scale-in bg-popover border-border",children:d.map(h=>e.jsxs("button",{onClick:()=>{h.action(),l(!1)},className:"w-full flex items-center gap-3 px-3 py-2.5 text-sm transition-colors hover:bg-muted text-left",children:[e.jsx("span",{className:"text-muted-foreground",children:h.icon}),h.label]},h.label))})]})},Zt=(n="")=>{const[r,u]=o.useState([{content:n}]),[s,l]=o.useState(0),a=o.useRef(0),d=o.useCallback((k,p)=>{const m=Date.now();m-a.current<500||(a.current=m,u(b=>{const N=b.slice(0,s+1);return N[N.length-1]?.content===k?b:(N.length>=100&&N.shift(),[...N,{content:k,cursorPosition:p}])}),l(b=>Math.min(b+1,99)))},[s]),h=o.useCallback(()=>s>0?(l(s-1),r[s-1]):null,[s,r]),g=o.useCallback(()=>s<r.length-1?(l(s+1),r[s+1]):null,[s,r]),y=s>0,x=s<r.length-1;return{saveToHistory:d,undo:h,redo:g,canUndo:y,canRedo:x}},qt=[{pattern:/^# (.+)$/,replacement:(n,r)=>`<h1>${r}</h1>`,format:"h1"},{pattern:/^## (.+)$/,replacement:(n,r)=>`<h2>${r}</h2>`,format:"h2"},{pattern:/^### (.+)$/,replacement:(n,r)=>`<h3>${r}</h3>`,format:"h3"},{pattern:/^- (.+)$/,replacement:(n,r)=>`<ul><li>${r}</li></ul>`,format:"unorderedList"},{pattern:/^\* (.+)$/,replacement:(n,r)=>`<ul><li>${r}</li></ul>`,format:"unorderedList"},{pattern:/^\d+\. (.+)$/,replacement:(n,r)=>`<ol><li>${r}</li></ol>`,format:"orderedList"},{pattern:/^- \[ \] (.+)$/,replacement:(n,r)=>`<div class="task-item"><span class="task-checkbox"></span><span class="task-text">${r}</span></div>`,format:"taskList"},{pattern:/^- \[x\] (.+)$/i,replacement:(n,r)=>`<div class="task-item"><span class="task-checkbox checked"></span><span class="task-text completed">${r}</span></div>`,format:"taskList"},{pattern:/^> (.+)$/,replacement:(n,r)=>`<blockquote>${r}</blockquote>`,format:"blockquote"},{pattern:/^```(.*)$/,replacement:()=>"<pre><code></code></pre>",format:"code"},{pattern:/^---$/,replacement:()=>"<hr>"},{pattern:/^\*\*\*$/,replacement:()=>"<hr>"}],$t=[{pattern:/\*\*(.+?)\*\*/,replacement:(n,r)=>`<strong>${r}</strong>`},{pattern:/__(.+?)__/,replacement:(n,r)=>`<strong>${r}</strong>`},{pattern:/\*(.+?)\*/,replacement:(n,r)=>`<em>${r}</em>`},{pattern:/_(.+?)_/,replacement:(n,r)=>`<em>${r}</em>`},{pattern:/~~(.+?)~~/,replacement:(n,r)=>`<s>${r}</s>`},{pattern:/`(.+?)`/,replacement:(n,r)=>`<code>${r}</code>`},{pattern:/\[(.+?)\]\((.+?)\)/,replacement:(n,r,u)=>`<a href="${u}">${r}</a>`}],en=()=>{const n=o.useCallback(u=>{for(const{pattern:l,replacement:a,format:d}of qt)if(u.match(l))return{html:u.replace(l,a),format:d};let s=u;for(const{pattern:l,replacement:a}of $t)s=s.replace(l,a);return s!==u?{html:`<p>${s}</p>`}:{html:u}},[]),r=o.useCallback(u=>{const s=[];if(!u)return s;let l=u;for(;l;){const a=l.tagName?.toLowerCase();(a==="strong"||a==="b")&&s.push("bold"),(a==="em"||a==="i")&&s.push("italic"),a==="u"&&s.push("underline"),(a==="s"||a==="strike"||a==="del")&&s.push("strikethrough"),a==="code"&&l.parentElement?.tagName?.toLowerCase()!=="pre"&&s.push("inlineCode"),a==="pre"&&s.push("code"),a==="blockquote"&&s.push("blockquote"),a==="ul"&&s.push("unorderedList"),a==="ol"&&s.push("orderedList"),a==="h1"&&s.push("h1"),a==="h2"&&s.push("h2"),a==="h3"&&s.push("h3"),l.classList?.contains("task-list")&&s.push("taskList"),l=l.parentElement}return[...new Set(s)]},[]);return{processMarkdown:n,detectActiveFormats:r}},ee="docuedit_documents",tn=5e3,jt=50,nn=(n="default")=>{const[r,u]=o.useState({currentDocumentId:n,versions:[],lastSaved:null,isSaving:!1}),s=o.useRef(""),l=o.useRef(null);o.useEffect(()=>{const p=localStorage.getItem(ee);if(p)try{const b=JSON.parse(p)[n]||[];u(N=>({...N,versions:b,lastSaved:b.length>0?b[b.length-1].timestamp:null}))}catch(m){console.error("Failed to load autosave data:",m)}},[n]);const a=o.useCallback((p,m=!1)=>{const b=localStorage.getItem(ee),N=b?JSON.parse(b):{},M=Date.now(),R=N[n]||[];if(m||R.length===0){const I={id:`v_${M}`,content:p,timestamp:M,title:`Version ${R.length+1}`};R.push(I),R.length>jt&&R.splice(0,R.length-jt)}else R.length>0&&(R[R.length-1]={...R[R.length-1],content:p,timestamp:M});N[n]=R,localStorage.setItem(ee,JSON.stringify(N)),u(I=>({...I,versions:R,lastSaved:M,isSaving:!1}))},[n]),d=o.useCallback((p,m=!1)=>{s.current=p,u(b=>({...b,isSaving:!0})),setTimeout(()=>{a(p,m)},100)},[a]),h=o.useCallback(()=>{s.current&&a(s.current,!0)},[a]),g=o.useCallback(p=>r.versions.find(b=>b.id===p)?.content||null,[r.versions]),y=o.useCallback(()=>r.versions.length===0?null:r.versions[r.versions.length-1].content,[r.versions]),x=o.useCallback(p=>{const m=localStorage.getItem(ee),b=m?JSON.parse(m):{},M=(b[n]||[]).filter(R=>R.id!==p);b[n]=M,localStorage.setItem(ee,JSON.stringify(b)),u(R=>({...R,versions:M}))},[n]),k=o.useCallback(()=>{const p=localStorage.getItem(ee),m=p?JSON.parse(p):{};delete m[n],localStorage.setItem(ee,JSON.stringify(m)),u(b=>({...b,versions:[],lastSaved:null}))},[n]);return o.useEffect(()=>(l.current=setInterval(()=>{s.current&&a(s.current,!1)},tn),()=>{l.current&&clearInterval(l.current)}),[a]),{save:d,createVersionSnapshot:h,loadVersion:g,getLatestContent:y,deleteVersion:x,clearAllVersions:k,versions:r.versions,lastSaved:r.lastSaved,isSaving:r.isSaving}},rn=n=>{let r=n;r=r.replace(/<div class="task-list">([\s\S]*?)<\/div>/gi,(s,l)=>l),r=r.replace(/<div class="task-item">([\s\S]*?)<\/div>/gi,(s,l)=>{const a=l.includes("checked"),d=l.match(/<span class="task-text"[^>]*>([\s\S]*?)<\/span>/i),h=d?d[1].trim():"";return a?`- [x] ${h}
15
- `:`- [ ] ${h}
16
- `}),r=r.replace(/<span class="task-checkbox[^"]*"[^>]*><\/span>/gi,""),r=r.replace(/<span class="task-text"[^>]*>([\s\S]*?)<\/span>/gi,"$1"),r=r.replace(/<h1[^>]*>([\s\S]*?)<\/h1>/gi,`# $1
17
-
18
- `),r=r.replace(/<h2[^>]*>([\s\S]*?)<\/h2>/gi,`## $1
19
-
20
- `),r=r.replace(/<h3[^>]*>([\s\S]*?)<\/h3>/gi,`### $1
21
-
22
- `),r=r.replace(/<h4[^>]*>([\s\S]*?)<\/h4>/gi,`#### $1
23
-
24
- `),r=r.replace(/<h5[^>]*>([\s\S]*?)<\/h5>/gi,`##### $1
25
-
26
- `),r=r.replace(/<h6[^>]*>([\s\S]*?)<\/h6>/gi,`###### $1
27
-
28
- `),r=r.replace(/<strong[^>]*>([\s\S]*?)<\/strong>/gi,"**$1**"),r=r.replace(/<b[^>]*>([\s\S]*?)<\/b>/gi,"**$1**"),r=r.replace(/<em[^>]*>([\s\S]*?)<\/em>/gi,"*$1*"),r=r.replace(/<i[^>]*>([\s\S]*?)<\/i>/gi,"*$1*"),r=r.replace(/<u[^>]*>([\s\S]*?)<\/u>/gi,"<u>$1</u>"),r=r.replace(/<s[^>]*>([\s\S]*?)<\/s>/gi,"~~$1~~"),r=r.replace(/<strike[^>]*>([\s\S]*?)<\/strike>/gi,"~~$1~~"),r=r.replace(/<pre[^>]*><code[^>]*>([\s\S]*?)<\/code><\/pre>/gi,"```\n$1\n```\n\n"),r=r.replace(/<code[^>]*>([\s\S]*?)<\/code>/gi,"`$1`"),r=r.replace(/<a[^>]*href="([^"]*)"[^>]*>([\s\S]*?)<\/a>/gi,"[$2]($1)"),r=r.replace(/<img[^>]*src="([^"]*)"[^>]*alt="([^"]*)"[^>]*\/?>/gi,"![$2]($1)"),r=r.replace(/<img[^>]*src="([^"]*)"[^>]*\/?>/gi,"![]($1)"),r=r.replace(/<ul[^>]*>([\s\S]*?)<\/ul>/gi,(s,l)=>l.replace(/<li[^>]*>([\s\S]*?)<\/li>/gi,`- $1
29
- `)+`
30
- `),r=r.replace(/<ol[^>]*>([\s\S]*?)<\/ol>/gi,(s,l)=>{let a=0;return l.replace(/<li[^>]*>([\s\S]*?)<\/li>/gi,()=>(a++,`${a}. $1
31
- `))+`
32
- `}),r=r.replace(/<blockquote[^>]*>([\s\S]*?)<\/blockquote>/gi,(s,l)=>l.split(`
33
- `).map(a=>`> ${a}`).join(`
34
- `)+`
35
-
36
- `),r=r.replace(/<hr[^>]*\/?>/gi,`
37
- ---
38
-
39
- `),r=r.replace(/<p[^>]*>([\s\S]*?)<\/p>/gi,`$1
40
-
41
- `),r=r.replace(/<br[^>]*\/?>/gi,`
42
- `),r=r.replace(/<div[^>]*>([\s\S]*?)<\/div>/gi,`$1
43
- `),r=r.replace(/<[^>]+>/g,""),r=r.replace(/\n{3,}/g,`
44
-
45
- `),r=r.trim();const u=document.createElement("textarea");return u.innerHTML=r,r=u.value,r},sn=(n,r="Document")=>{const u=window.open("","_blank");if(!u){alert("Please allow pop-ups to export PDF");return}u.document.write(`
46
- <!DOCTYPE html>
47
- <html>
48
- <head>
49
- <title>${r}</title>
50
-
51
- <style>
52
- body {
53
- font-family: 'Georgia', serif;
54
- max-width: 800px;
55
- margin: 40px auto;
56
- padding: 20px;
57
- line-height: 1.6;
58
- color: #333;
59
- }
60
- h1 { font-size: 2.5em; margin-bottom: 0.5em; }
61
- h2 { font-size: 2em; margin-bottom: 0.4em; margin-top: 1.5em; }
62
- h3 { font-size: 1.5em; margin-bottom: 0.3em; margin-top: 1.2em; }
63
- p { margin-bottom: 1em; }
64
- blockquote {
65
- border-left: 3px solid #3b82f6;
66
- padding-left: 1em;
67
- margin: 1em 0;
68
- color: #555;
69
- font-style: italic;
70
- }
71
- pre {
72
- background: #f5f5f5;
73
- padding: 1em;
74
- border-radius: 4px;
75
- overflow-x: auto;
76
- }
77
- code {
78
- background: #f5f5f5;
79
- padding: 0.2em 0.4em;
80
- border-radius: 3px;
81
- font-family: 'Consolas', monospace;
82
- }
83
- pre code { background: transparent; padding: 0; }
84
- ul, ol { margin: 1em 0; padding-left: 2em; }
85
- li { margin-bottom: 0.5em; }
86
- hr { border: none; border-top: 2px solid #eee; margin: 2em 0; }
87
- img { max-width: 100%; height: auto; }
88
- table { border-collapse: collapse; width: 100%; margin: 1em 0; }
89
- th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
90
- th { background: #f5f5f5; }
91
- .task-list { list-style: none; padding-left: 0; }
92
- .task-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
93
- .task-checkbox { width: 16px; height: 16px; border: 2px solid #888; border-radius: 3px; display: inline-block; }
94
- .task-checkbox.checked { background: #3b82f6; border-color: #3b82f6; }
95
- </style>
96
-
97
- </head>
98
- <body>
99
- ${n}
100
- </body>
101
- </html>
102
- `),u.document.close(),setTimeout(()=>{u.print()},500)},kt=(n,r,u)=>{const s=new Blob([n],{type:u}),l=URL.createObjectURL(s),a=document.createElement("a");a.href=l,a.download=r,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(l)},on=()=>{const n=o.useCallback((s,l="document")=>{const a=`<!DOCTYPE html>
103
- <html lang="en">
104
- <head>
105
- <meta charset="UTF-8">
106
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
107
- <title>${l}</title>
108
- <style>
109
- body { font-family: Georgia, serif; max-width: 800px; margin: 40px auto; padding: 20px; line-height: 1.6; }
110
- h1 { font-size: 2.5em; }
111
- h2 { font-size: 2em; }
112
- h3 { font-size: 1.5em; }
113
- blockquote { border-left: 3px solid #3b82f6; padding-left: 1em; color: #555; font-style: italic; }
114
- pre { background: #f5f5f5; padding: 1em; border-radius: 4px; }
115
- code { background: #f5f5f5; padding: 0.2em 0.4em; border-radius: 3px; font-family: Consolas, monospace; }
116
- pre code { background: transparent; }
117
- img { max-width: 100%; }
118
- table { border-collapse: collapse; width: 100%; }
119
- th, td { border: 1px solid #ddd; padding: 8px; }
120
- th { background: #f5f5f5; }
121
- </style>
122
- </head>
123
- <body>
124
- ${s}
125
- </body>
126
- </html>`;kt(a,`${l}.html`,"text/html")},[]),r=o.useCallback((s,l="document")=>{const a=rn(s);kt(a,`${l}.md`,"text/markdown")},[]),u=o.useCallback((s,l="Document")=>{sn(s,l)},[]);return{exportHTML:n,exportMarkdown:r,exportPDF:u}},an={bold:!1,italic:!1,underline:!1,strikethrough:!1,orderedList:!1,unorderedList:!1,taskList:!1,blockquote:!1,code:!1,heading:"p"},ln=()=>{const n=o.useRef(null),[r,u]=o.useState(an),[s,l]=o.useState("dm-sans"),[a,d]=o.useState(!1),[h,g]=o.useState(""),y=o.useRef(null),[x,k]=o.useState(!1),[p,m]=o.useState({top:0,left:0}),[b,N]=o.useState(""),[M,R]=o.useState(!1),[I,Q]=o.useState(!1),[E,F]=o.useState(!1),{saveToHistory:H,undo:se,redo:we,canUndo:Ce,canRedo:Ve}=Zt(),{detectActiveFormats:Ne}=en(),{save:B,versions:G,lastSaved:J,loadVersion:Z,deleteVersion:Le,getLatestContent:Se,createVersionSnapshot:me}=nn(),{exportHTML:Re,exportMarkdown:Te,exportPDF:Ee}=on();o.useEffect(()=>{const c=Se();c&&n.current&&(n.current.innerHTML=c)},[]);const W=o.useCallback(()=>{const c=window.getSelection();if(!c||!c.rangeCount)return;const L=c.getRangeAt(0).commonAncestorContainer.parentElement,v=Ne(L);u({bold:v.includes("bold")||document.queryCommandState("bold"),italic:v.includes("italic")||document.queryCommandState("italic"),underline:v.includes("underline")||document.queryCommandState("underline"),strikethrough:v.includes("strikethrough")||document.queryCommandState("strikeThrough"),orderedList:v.includes("orderedList"),unorderedList:v.includes("unorderedList"),taskList:v.includes("taskList"),blockquote:v.includes("blockquote"),code:v.includes("code")||v.includes("inlineCode"),heading:v.find(D=>D.match(/^h[1-3]$/))||"p"})},[Ne]),z=o.useCallback(c=>{if(n.current){switch(n.current.focus(),c){case"bold":document.execCommand("bold",!1);break;case"italic":document.execCommand("italic",!1);break;case"underline":document.execCommand("underline",!1);break;case"strikethrough":document.execCommand("strikeThrough",!1);break;case"orderedList":document.execCommand("insertOrderedList",!1);break;case"unorderedList":document.execCommand("insertUnorderedList",!1);break;case"taskList":Fe();break;case"blockquote":Ue();break;case"code":he();break;case"inlineCode":pe("code");break;case"horizontalRule":document.execCommand("insertHorizontalRule",!1);break;case"paragraph":document.execCommand("formatBlock",!1,"p");break;case"h1":case"h2":case"h3":document.execCommand("formatBlock",!1,c);break;case"image":R(!0);return;case"table":Q(!0);return}H(n.current.innerHTML),B(n.current.innerHTML),W()}},[H,W,B]),Fe=()=>{document.execCommand("insertHTML",!1,`<div class="task-list"><div class="task-item"><span class="task-checkbox" onclick="this.classList.toggle('checked'); this.nextElementSibling.classList.toggle('completed');"></span><span class="task-text" contenteditable="true">Task item</span></div></div>`)},Ue=()=>{const c=window.getSelection();if(!c||!c.rangeCount)return;const L=c.getRangeAt(0).commonAncestorContainer.parentElement?.closest("blockquote");if(L){const v=L.innerHTML;L.outerHTML=`<p>${v}</p>`}else{const v=c.toString()||"Quote text here...";document.execCommand("insertHTML",!1,`<blockquote>${v}</blockquote>`)}},he=()=>{const c=window.getSelection();if(!c||!c.rangeCount)return;const w=c.toString()||"Code here...";document.execCommand("insertHTML",!1,`<pre><code>${w}</code></pre><p></p>`)},pe=c=>{const w=window.getSelection();if(!w||!w.rangeCount||w.isCollapsed)return;const L=w.getRangeAt(0),v=L.toString(),D=L.commonAncestorContainer.parentElement;if(D?.tagName?.toLowerCase()===c){const K=document.createTextNode(v);D.replaceWith(K)}else document.execCommand("insertHTML",!1,`<${c}>${v}</${c}>`)},X=o.useCallback((c,w)=>{if(!n.current)return;n.current.focus();const L=`<img src="${c}" alt="${w||""}" class="editor-image" style="max-width: 100%; border-radius: 8px;" /><p></p>`;document.execCommand("insertHTML",!1,L),H(n.current.innerHTML),B(n.current.innerHTML),R(!1)},[H,B]),xe=o.useCallback((c,w)=>{if(!n.current)return;n.current.focus();let L='<table class="editor-table"><thead><tr>';for(let v=0;v<w;v++)L+="<th>Header</th>";L+="</tr></thead><tbody>";for(let v=0;v<c-1;v++){L+="<tr>";for(let D=0;D<w;D++)L+="<td>Cell</td>";L+="</tr>"}L+="</tbody></table><p></p>",document.execCommand("insertHTML",!1,L),H(n.current.innerHTML),B(n.current.innerHTML),Q(!1)},[H,B]),q=o.useCallback(c=>{n.current&&(n.current.focus(),document.execCommand("formatBlock",!1,c==="p"?"p":c),H(n.current.innerHTML),B(n.current.innerHTML),W())},[H,W,B]),ze=o.useCallback(c=>{l(c.value)},[]),oe=o.useCallback(()=>{const c=se();c&&n.current&&(n.current.innerHTML=c.content,W())},[se,W]),ge=o.useCallback(()=>{const c=we();c&&n.current&&(n.current.innerHTML=c.content,W())},[we,W]),ae=o.useCallback(()=>{const c=window.getSelection();c&&c.rangeCount>0&&(y.current=c.getRangeAt(0).cloneRange(),g(c.toString())),d(!0)},[]),ie=o.useCallback((c,w)=>{if(!n.current)return;if(n.current.focus(),y.current){const v=window.getSelection();v?.removeAllRanges(),v?.addRange(y.current)}const L=w||h||c;document.execCommand("insertHTML",!1,`<a href="${c}" target="_blank" rel="noopener noreferrer">${L}</a>`),H(n.current.innerHTML),B(n.current.innerHTML),d(!1),g(""),y.current=null},[h,H,B]),te=o.useCallback(c=>{if(!n.current)return;const w=window.getSelection();if(w&&w.rangeCount>0){const v=w.getRangeAt(0).startContainer;if(v.nodeType===Node.TEXT_NODE&&v.textContent){const D=v.textContent.lastIndexOf("/");D>=0&&(v.textContent=v.textContent.substring(0,D))}}k(!1),N(""),z(c)},[z]),_e=o.useCallback(c=>{const L=navigator.platform.toUpperCase().indexOf("MAC")>=0?c.metaKey:c.ctrlKey;if(c.key==="Escape"&&x){k(!1);return}if(L)switch(c.key.toLowerCase()){case"b":c.preventDefault(),z("bold");break;case"i":c.preventDefault(),z("italic");break;case"u":c.preventDefault(),z("underline");break;case"k":c.preventDefault(),ae();break;case"s":c.preventDefault(),me();break;case"z":c.preventDefault(),c.shiftKey?ge():oe();break}if(c.key===" "||c.key==="Enter"){const v=window.getSelection();if(!v||!v.rangeCount)return;const D=v.getRangeAt(0),K=D.startContainer.textContent||"",ne=D.startOffset,Ge=K.substring(0,ne),Xe=[{regex:/^# $/,format:"h1",heading:"h1"},{regex:/^## $/,format:"h2",heading:"h2"},{regex:/^### $/,format:"h3",heading:"h3"},{regex:/^- $/,format:"unorderedList"},{regex:/^\* $/,format:"unorderedList"},{regex:/^\d+\. $/,format:"orderedList"},{regex:/^> $/,format:"blockquote"},{regex:/^- \[ \] $/,format:"taskList"},{regex:/^```$/,format:"code"},{regex:/^---$/,format:"horizontalRule"}];for(const{regex:Qe,format:Ze,heading:Ie}of Xe)if(Qe.test(Ge)){c.preventDefault();const De=D.startContainer;De.nodeType===Node.TEXT_NODE&&(De.textContent=""),Ie?q(Ie):z(Ze);return}}},[z,q,ae,oe,ge,x,me]),Me=o.useCallback(()=>{if(!n.current)return;const c=window.getSelection();if(c&&c.rangeCount>0){const w=c.getRangeAt(0),L=w.startContainer.textContent||"",v=w.startOffset,K=L.substring(0,v).match(/\/([a-zA-Z]*)$/);if(K){const ne=w.getBoundingClientRect();m({top:ne.bottom+8,left:ne.left}),N(K[1]),k(!0)}else k(!1)}H(n.current.innerHTML),B(n.current.innerHTML),W()},[H,W,B]),le=o.useCallback(c=>{const w=c.clipboardData.items;for(const L of w)if(L.type.startsWith("image/")){c.preventDefault();const v=L.getAsFile();if(v){const D=new FileReader;D.onload=K=>{X(K.target?.result)},D.readAsDataURL(v)}return}},[X]),Ye=o.useCallback(c=>{const w=c.dataTransfer.files;for(const L of w)if(L.type.startsWith("image/")){c.preventDefault();const v=new FileReader;v.onload=D=>{X(D.target?.result)},v.readAsDataURL(L);return}},[X]),Je=o.useCallback(c=>{const w=Z(c);w&&n.current&&(n.current.innerHTML=w,H(w),B(w,!0),F(!1))},[Z,H,B]);o.useEffect(()=>{const c=()=>W();return document.addEventListener("selectionchange",c),()=>document.removeEventListener("selectionchange",c)},[W]);const be=()=>({"dm-sans":"font-sans-editor",merriweather:"font-serif-editor",playfair:"font-display-editor",jetbrains:"font-mono-editor",arial:"font-arial",georgia:"font-georgia",verdana:"font-verdana",courier:"font-courier",times:"font-times"})[s]||"font-sans-editor",Ke=()=>{if(!J)return"Not saved yet";const c=Date.now()-J;return c<6e4?"Just now":c<36e5?`${Math.floor(c/6e4)} min ago`:new Date(J).toLocaleTimeString()};return e.jsxs("div",{className:"w-full max-w-4xl mx-auto",children:[e.jsxs("div",{className:"rounded-xl border shadow-toolbar overflow-hidden bg-card border-editor-border",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-muted/30",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("button",{onClick:()=>F(!0),className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(Ae,{className:"w-4 h-4"}),e.jsxs("span",{children:["Saved ",Ke()]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>R(!0),className:"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium transition-colors hover:bg-muted text-muted-foreground hover:text-foreground",children:[e.jsx(Oe,{className:"w-4 h-4"}),"Image"]}),e.jsxs("button",{onClick:()=>Q(!0),className:"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium transition-colors hover:bg-muted text-muted-foreground hover:text-foreground",children:[e.jsx(Pe,{className:"w-4 h-4"}),"Table"]}),e.jsx(Qt,{onExportHTML:()=>Re(n.current?.innerHTML||"","document"),onExportMarkdown:()=>Te(n.current?.innerHTML||"","document"),onExportPDF:()=>Ee(n.current?.innerHTML||"","Document")})]})]}),e.jsx(Ft,{formatState:r,currentFont:s,onFormat:z,onFontChange:ze,onHeadingChange:q,onUndo:oe,onRedo:ge,canUndo:Ce,canRedo:Ve,onInsertLink:ae}),e.jsxs("div",{ref:n,className:`editor-content p-6 md:p-8 min-h-[500px] focus:outline-none ${be()} bg-editor`,contentEditable:!0,onInput:Me,onKeyDown:_e,onPaste:le,onDrop:Ye,onDragOver:c=>c.preventDefault(),suppressContentEditableWarning:!0,"data-placeholder":"Start writing... Type '/' for commands, or use markdown shortcuts like # for headings",children:[e.jsx("h1",{children:"Welcome to DocuEdit"}),e.jsxs("p",{children:["A powerful rich text editor with ",e.jsx("strong",{children:"autosave"}),", ",e.jsx("em",{children:"version history"}),", and ",e.jsx("u",{children:"export"})," features."]}),e.jsx("h2",{children:"Quick Commands"}),e.jsxs("ul",{children:[e.jsxs("li",{children:["Type ",e.jsx("code",{children:"/"})," to open the slash command menu"]}),e.jsx("li",{children:"Drag & drop or paste images directly"}),e.jsxs("li",{children:["Press ",e.jsx("code",{children:"Ctrl/Cmd + S"})," to create a version snapshot"]})]}),e.jsx("h3",{children:"Export Options"}),e.jsx("p",{children:"Export your document as HTML, Markdown, or PDF using the export menu above."})]})]}),e.jsx(Ut,{formatState:{bold:r.bold,italic:r.italic,underline:r.underline,strikethrough:r.strikethrough,code:r.code},onFormat:z,onInsertLink:ae,editorRef:n}),e.jsx(Jt,{isOpen:x,position:p,searchQuery:b,onSelect:te,onClose:()=>k(!1)}),e.jsx(zt,{isOpen:a,onClose:()=>d(!1),onInsert:ie,selectedText:h}),e.jsx(Kt,{isOpen:M,onClose:()=>R(!1),onInsert:X}),e.jsx(Gt,{isOpen:I,onClose:()=>Q(!1),onInsert:xe}),e.jsx(Xt,{isOpen:E,onClose:()=>F(!1),versions:G,onRestore:Je,onDelete:Le})]})};$.RichTextEditor=ln,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})}));